363 Commits

Author SHA1 Message Date
Serge
ba2871aa34 Update commands bc, egrep, expr, iostat, mail, ps, su, vmstat, wall, write. 2022-07-10 22:14:32 -07:00
Serge
edde805980 Update tail, tar, tee, time, touch, tr, tsort, tty, uniq, w, wc, whereis, who. 2022-07-10 20:07:46 -07:00
Serge
db74d0da32 Update pwd, rev, rm, rmail, rmdir, size, sleep, sort, split, sum, sync. 2022-07-10 19:03:28 -07:00
Serge
1253330adc Update kill, last, ln, mesg, mkdir, mv, nice, od, pagesize, pr, printenv. 2022-07-10 18:33:12 -07:00
Serge
26e2d7dd5e Update du, echo, ed, fgrep, file, grep, head, hostid, join. 2022-07-10 17:35:59 -07:00
Serge
9c3b2e0d9a Update basename, cal, cat, cb, chgrp, chmod, cmp, col, comm, cp, dd. 2022-07-10 16:33:56 -07:00
Serge
51da6c0e6e Update pstat, reboot, shutdown, update, vipw, virus. 2022-07-10 15:00:28 -07:00
Serge
dbe1779a29 Update mkfs, mknod, mkpasswd, mount. 2022-07-10 14:19:42 -07:00
Serge
c6f46414ed Update getty. 2022-06-19 20:44:39 -07:00
Serge
552f5ed4c2 Update chroot and fsck. 2022-06-18 22:53:38 -07:00
Serge
2d61fa76c3 Update yacc. 2022-06-18 22:44:41 -07:00
Serge
72d7321b45 Reindent yacc sources. 2022-06-18 22:00:26 -07:00
Serge
82817c9308 Update uucp. 2022-06-18 21:50:44 -07:00
Serge
c849b8f1f8 Update date2 and tip. 2022-06-18 15:10:26 -07:00
Serge
1febcc5f9f Update cron and gtest. 2022-06-18 14:51:24 -07:00
Serge
7b1d52abff Update src/cmd/Makefile. 2022-06-12 22:49:06 -07:00
Serge
2f2d84e6a0 Update stty, sysctl, test, uname, xargs, zmodem. 2022-06-12 21:53:58 -07:00
Serge
6794c38ff4 Update smlrc. 2022-06-12 20:02:11 -07:00
Serge
840cd1db8b Update smallc. 2022-06-12 19:46:53 -07:00
Serge
f6602a8a6d Update cmd/sh. 2022-05-28 00:39:33 -07:00
Serge
97dfd3ae89 Update sed. 2022-05-27 21:54:16 -07:00
Serge
e728e7f25d Update cmd/re and scm. 2022-05-27 21:12:40 -07:00
Serge
146bae8a98 Update cmd/picoc. 2022-05-27 20:39:20 -07:00
Serge
724973121b Update cmd/more. 2022-05-27 19:24:20 -07:00
Serge
cc59786ed6 Update man, md5 and med. 2022-05-27 18:32:55 -07:00
Serge
4c51256273 Update cmd/login. 2022-05-27 18:11:42 -07:00
Serge
27ddb2eef0 Update lex and ls. 2022-05-27 17:47:38 -07:00
Serge
c213981071 Update glcdtest, hostname, id. 2022-05-27 17:22:07 -07:00
Serge
75302a4eec Implement sqrtf() as a wrapper around sqrt(), for simplicity. 2022-05-27 17:14:04 -07:00
Serge
2252835438 Update cmd/find. 2022-05-27 16:08:38 -07:00
Serge
9e2d5993f6 Update diff and emg. 2022-05-27 02:26:28 -07:00
Serge
a47779d9d6 Update cmd/dc. 2022-05-27 01:23:51 -07:00
Serge
bd9f0208d2 Fix chpass. 2022-05-27 00:46:24 -07:00
Serge
4fdec2101b Move libclang into libc.
Catch all warnings.
2022-05-27 00:20:07 -07:00
Serge
9c50b5a97d Update kernel makefiles. 2022-05-26 00:55:10 -07:00
Serge
37d1b00b7c Update awk. 2022-05-26 00:50:08 -07:00
Serge
716151b46f Update awk and libm. 2022-05-26 00:23:40 -07:00
Serge
8458c9e3c4 Fix linking of user programs.
Start fixing awk.
2022-05-25 23:05:45 -07:00
Serge
4e2c809150 Fix linker script.
Skip empty GNU_STACK section in elf2aout utility.
2022-05-25 22:33:30 -07:00
Serge
ef83392732 Add library libclang: low level support routines from
llvm-project/compiler-rt/lib/builtins collection.
2022-05-25 21:36:20 -07:00
Serge
9d5c61e023 adb: declare all global variables as extern, and define them in main.c. 2022-05-25 20:21:33 -07:00
Serge
d5002ad0ac Use LD for linking mips binaries, not CC.
Fix a few incompatibilities in C sources.
2022-05-25 19:23:39 -07:00
Serge
00c4bf1ea1 Modify makefile in lib/startup to pass options to external assembler. 2022-05-25 18:17:29 -07:00
Serge
9f617eb6fe Modify build scripts for clang.
Disable -mips16 flag for now.
Fix a few issues and incompatibilities detected by compiler.
2022-05-25 17:38:22 -07:00
Serge Vakulenko
71faeb6c76 Disable mount option in fsutil. No need for libfuse anymore.
Fix build issues in virtualmips simulator.
2022-05-25 16:11:07 -07:00
Serge Vakulenko
a0c256c1f0 Virus editor crashed when colon command line exceeded 4 bytes.
Fixed issue #79.
2019-02-17 14:24:26 -08:00
Serge Vakulenko
9d8ad7ccf5 Configure gpanel driver for Duinomite board. 2018-01-30 20:35:01 -08:00
Serge Vakulenko
a5d7f4ea99 Gpanel driver: add support for ILI9481 LCD controller. 2018-01-30 20:22:36 -08:00
Serge Vakulenko
435d3c34cf Fix build errors and warnings in zoneinfo and virtualmips. 2018-01-30 20:20:38 -08:00
Serge Vakulenko
0e39621fea Merge pull request #77 from 610t/master
Retern to legacy implement for expr(1) etc.
2017-02-14 23:25:59 -08:00
Takeshi MUTOH
7477abe7f3 Retern to legacy implement for expr(1) etc. 2017-02-12 06:19:13 +09:00
Serge Vakulenko
7075769d7c Merge pull request #76 from vasily122/insert-int
insert definitions of INT in some functions
2016-12-31 14:10:02 -08:00
vasily122
f5452b74de insert definitions of INT in some functions 2016-11-04 13:46:37 +00:00
Matt Jenkins
f3dbdc7615 Got Yacc compiling and running 2016-07-14 00:06:12 +01:00
Matt Jenkins
66e5cd88c0 Fixed UECIDE compiler location detection 2016-07-14 00:04:45 +01:00
Matt Jenkins
0583055d00 Added PONTECH Quick240 2016-07-14 00:02:22 +01:00
Matt Jenkins
aea2050c49 Merge branch 'master' of github.com:RetroBSD/retrobsd 2016-07-13 16:02:46 +01:00
Serge Vakulenko
5fde14ecea Fix bus frequency and gpio configuration for eMega board. 2016-07-12 17:39:08 -07:00
Serge Vakulenko
ca67f33a30 Autobuild: add Olimex Duinomite-eMega board. 2016-07-07 20:46:14 -07:00
Matt Jenkins
20238b7208 Merge branch 'master' of github.com:RetroBSD/retrobsd 2016-07-03 16:48:42 +01:00
Serge Vakulenko
1a7125b892 Merge pull request #74 from ibara/master
RetroBSD now builds on FreeBSD.
2016-06-23 10:23:34 -07:00
Brian Callahan
d048ee200e RetroBSD now builds on FreeBSD. 2016-06-13 06:47:48 -04:00
Matt Jenkins
6ddcb56e2a Made elf2aout compilable for windows under linux 2016-02-15 15:12:21 +00:00
Serge Vakulenko
148bb1cac6 Merge pull request #72 from alexfru/master
Improve *printf()
2016-01-24 22:16:14 -08:00
Alexey Frunze
b2bde490b4 Improve *printf()
- support %i in addition to %d
- print the sign when printing 0 with %+d
2016-01-24 18:38:58 -08:00
Serge Vakulenko
e1d3583dcd Merge pull request #71 from alexfru/master
Fix infinite loop in ldexp(0.0, any).
2016-01-24 01:55:25 -08:00
Alexey Frunze
21f8d60095 Fix infinite loop in ldexp(0.0, any). 2016-01-24 01:43:24 -08:00
Serge Vakulenko
6457d878c0 Merge pull request #70 from alexfru/master
Floating point improvements
2016-01-23 22:57:05 -08:00
Alexey Frunze
e5c844eff2 Floating point improvements
- Smaller C: fix a bug in __func__ introduced with
  float-related changes
- make *printf() print floats greater than 1e25
- make *printf() print the plus sign when the format
  includes "+", e.g. printf("%+f\n", 1.0);
- clean up and complete prototypes in <math.h>
- remove non-standard HUGE and LOGHUGE from <math.h>
- add HUGE_VAL to <math.h>
- express some hard-coded limits in terms of constants
  from <float.h>
- uncomment prototypes of several floating point
  conversion functions in <stdlib.h> for Smaller C
2016-01-23 19:47:14 -08:00
Serge Vakulenko
4e90456341 Merge pull request #69 from alexfru/master
Floats in Smaller C!
2016-01-16 23:35:14 -08:00
Alexey Frunze
bfc3125556 Floats in Smaller C!
double is an alias for float. IOW, only 32-bit
single precision floats are supported. This isn't
conformant, but OK for some embedded systems (e.g.
RetroBSD) and simple compilers like this.

Also, the following operators are not supported with
floats at the moment: ++, --, +=, -=, *=, /=.
But +, -, *, /, =, ||, &&, ?:, !, comparison, casts,
if/while/for are OK.
2016-01-16 22:45:42 -08:00
Serge Vakulenko
fa094d1744 libc: add missing functions __fixunssfsi() and __floatunsisf(). 2016-01-03 00:21:39 -08:00
Serge Vakulenko
b7a3d6f665 Enable uarts for pic32-retrobsd board.
Fix build issues with fuse library path on Mac OS X.
2015-12-30 19:20:37 -08:00
Serge Vakulenko
fb05f20fbe Merge pull request #66 from ibara/master
Update to emg-2.0
2015-12-17 22:21:49 -08:00
Brian Callahan
e050ac6ee6 Update to emg-2.0 2015-12-18 01:13:00 -05:00
Serge Vakulenko
8dd0fb4860 Flappy game: reduce flickering. 2015-12-03 21:43:43 -08:00
Serge Vakulenko
6028db705a Gpanel spi driver: read ID4 register to identify the ili9341 chip. 2015-12-03 21:25:57 -08:00
Serge Vakulenko
6d501bfc7c Update flappy game. 2015-11-30 12:47:45 -08:00
Serge Vakulenko
09205046a4 Move ILI9341 defines to a separate include file. 2015-11-28 00:44:40 -08:00
Serge Vakulenko
ac9ef0eee9 Add sgpanel driver: a generic TFT LCD graphics panel with SPI interface.
Currently only ILI8341 chip is supported.
2015-11-28 00:17:01 -08:00
Serge Vakulenko
e073fcbd64 SD driver: print information about the CMD6 function groups. 2015-11-27 17:26:09 -08:00
Serge Vakulenko
0507073b60 SD driver: use CMD6 command to switch the card into high-speed mode. 2015-11-26 17:25:25 -08:00
Serge Vakulenko
76cb491c09 Flappy Bird game: save high score to a file. 2015-11-23 13:41:13 -08:00
Serge Vakulenko
f3f28ceca5 Fix bug in gpanel fill triangle routine. 2015-11-22 15:04:41 -08:00
Serge Vakulenko
e3c86f0ffa Update Flappy Bird game. 2015-11-22 14:34:44 -08:00
Serge Vakulenko
7503ce7856 Add Flappy Bird game. 2015-11-22 01:47:52 -08:00
Serge Vakulenko
1a1daf15a3 Update ILI9341 LCD driver. 2015-11-22 00:19:14 -08:00
Serge Vakulenko
a40bcee878 Extend gpanel library with fill rectangle routine. 2015-11-21 23:10:45 -08:00
Serge Vakulenko
e67e939fb9 Add aclock game. 2015-11-20 22:44:37 -08:00
Serge Vakulenko
9027547fa6 Mend a font direction in ST7781 portrait unside down mode. 2015-11-20 21:54:34 -08:00
Serge Vakulenko
7c2aa43862 Fix bug in ST7781 driver. Set landscape mode by default. 2015-11-20 21:43:27 -08:00
Serge Vakulenko
8988b8b013 Reuse ili9341 routines for nt35702 display. 2015-11-19 22:10:52 -08:00
Serge Vakulenko
d2940a8719 Fix screen orientation in the ILI9341 LCD driver. 2015-11-19 19:55:07 -08:00
Serge Vakulenko
be1726a662 Draw a BSD logo on the LCD display at start. 2015-11-19 19:04:23 -08:00
Serge Vakulenko
2fd36d9175 Update ILI9341 LCD driver. 2015-11-17 19:25:39 -08:00
Serge Vakulenko
6f0a48330c LCD driver: add support for Samsung S6D04H0 (not finished yet). 2015-11-16 22:15:40 -08:00
Serge Vakulenko
4dd9308e25 Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-11-15 14:15:13 -08:00
Serge Vakulenko
98f3efcb70 Increase the max number of processes (NPROC) from 10 to 25. 2015-11-15 14:14:18 -08:00
Serge Vakulenko
2e716e099c LCD driver: fix garbage when a glyph extends off screen. 2015-11-15 13:39:08 -08:00
Serge Vakulenko
03ed62db5d Libm: add 32-bit variant of fmod() function. 2015-11-06 20:40:45 -08:00
Serge Vakulenko
c46bd3c1e9 Enable optimization by size (-Os) by default for all user binaries. 2015-11-03 22:03:52 -08:00
Serge Vakulenko
a673c028f8 Add ubw32 board to the autobuild list. 2015-11-03 21:37:50 -08:00
Serge Vakulenko
7ddf7686a3 Enable mips16e instruction set for all user binaries. 2015-11-03 21:36:31 -08:00
Serge Vakulenko
abcfb06b0b Merge gpanel branch. 2015-10-31 21:12:50 -07:00
Serge Vakulenko
e00196ee21 Merge branch 'master' into gpanel-driver 2015-10-31 21:11:38 -07:00
Serge Vakulenko
5b04c6b168 Add driver for ILI9341 display controller. 2015-10-31 21:09:44 -07:00
Serge Vakulenko
7f69510488 Gpanel driver: use gamma values from NT35702 datasheet. 2015-10-31 19:58:41 -07:00
Serge Vakulenko
058b6c4de0 Add support for NT35702 display controller. 2015-10-31 19:25:26 -07:00
Serge Vakulenko
1e4005cc4b Split the gpanel driver into chip-specific and generic parts. 2015-10-31 14:57:45 -07:00
Serge Vakulenko
66a7727085 Rename swtft -> gpanel. 2015-10-31 13:26:27 -07:00
Serge Vakulenko
2bfd3df2a6 Merge pull request #65 from alexfru/master
virtualmips: improve MIPS16e: save/restore, sdbbp
2015-10-31 00:52:49 -07:00
Alexey Frunze
162f0d34b5 virtualmips: improve MIPS16e: save/restore, sdbbp 2015-10-31 00:45:15 -07:00
Serge Vakulenko
3ee11917bb Add ili9341 sources from adafruit library, and nt35702 sources from elsewhere. 2015-10-30 20:44:07 -07:00
Serge Vakulenko
b259f58533 Virtualmips: merge changes from alexfru.
Fix bug in mips16 disassembler.
2015-10-30 10:47:11 -07:00
Serge Vakulenko
42fd2f99bd Remove unnecessary EHBs in kernel startup code. 2015-10-30 10:31:24 -07:00
Serge Vakulenko
ff8e4c81d0 Virtualmips: enhance printing of exception information. 2015-10-29 21:21:28 -07:00
Serge Vakulenko
691fdfaa2f Virtualmips: restored broken DI and EI instructions. 2015-10-29 21:06:56 -07:00
Serge Vakulenko
d8708af48a Virtualmips: handle overflow in div, add, addi and sub instructions. 2015-10-29 20:15:10 -07:00
Serge Vakulenko
7d3e799c82 Virtualmips: take CpU exception as expected. 2015-10-29 19:39:03 -07:00
Serge Vakulenko
91cbbfbad0 Virtualmips: SC instruction should take AdES exception even when LL bit is not set. 2015-10-29 19:01:19 -07:00
Serge Vakulenko
f87ab8d4c4 Virtualmips: remove unused opcodes. 2015-10-29 18:51:02 -07:00
Serge Vakulenko
37646559fd Virtualmips: implement CLO instruction. 2015-10-29 18:17:02 -07:00
Serge Vakulenko
1a5f550fe1 Virtualmips: merge changes from alexfru. 2015-10-29 18:11:41 -07:00
Serge Vakulenko
666f22786f Virtualmips: add DERET instruction. 2015-10-29 18:04:42 -07:00
Serge Vakulenko
8d15906495 Virtualmips: implement SDBBP instruction. 2015-10-29 17:44:44 -07:00
Serge Vakulenko
5bff2b428c Virtualmips: implement compare-and-trap instructions. 2015-10-29 14:02:08 -07:00
Serge Vakulenko
94d38c939f Virtualmips: fix disassembler for mips16e mode. 2015-10-29 13:34:45 -07:00
Serge Vakulenko
f2c4d11b74 Virtualmips: fix exception vectors. 2015-10-28 17:21:31 -07:00
Serge Vakulenko
ce4fbe98b7 Virtualmips: handle SRSCtl register as zero read-only. 2015-10-28 12:02:35 -07:00
Serge Vakulenko
ec2a748448 Virtualmips: implement magic opcodes. 2015-10-27 22:17:58 -07:00
Serge Vakulenko
ade0fff092 VirtualMIPS simulator: create a platform for generic M4K core. 2015-10-26 22:44:38 -07:00
Serge Vakulenko
d4dbb43d44 Merge pull request #64 from alexfru/master
Initial support for MIPS16e in virtualmips emulator
2015-10-26 16:01:32 -07:00
Alexey Frunze
f8bde663cf Initial support for MIPS16e in virtualmips emulator
Also:
- A few bugfixes in virtualmips
- Compile Smaller C (smlrc) using MIPS16e
  (this frees up ~20KB of space for smlrc improvements)
TBD:
- MIPS16e disassembler in virtualmips
2015-10-26 02:27:46 -07:00
Serge Vakulenko
c08045dafe Fix bug in zoneinfo compiler. 2015-10-25 15:59:54 -07:00
Serge Vakulenko
c1ff69edd2 Fix European timezones. 2015-10-20 13:30:41 -07:00
vak
7562e8e410 Install zoneinfo files. 2015-10-20 00:42:29 -07:00
Serge Vakulenko
b134c1f84c Timezone compiler updated. 2015-10-20 00:01:42 -07:00
Serge Vakulenko
0f920ee55a Add zoneinfo sources. 2015-10-19 23:40:54 -07:00
Serge Vakulenko
401d36eee7 Use names for st7781 registers. 2015-10-11 14:08:05 -07:00
Serge Vakulenko
8d820f763f Fix a timing in ST7781 driver.
All gpanel demos now work as expected.
2015-10-11 13:08:18 -07:00
Serge Vakulenko
2bb8bfabb3 Finish st7781 driver. 2015-10-10 23:31:26 -07:00
Serge Vakulenko
e82e5f2ce1 ST7781 driver compiled. 2015-10-10 21:39:27 -07:00
Sergey
e8572fdfd7 Delete file hx8357.h.
Use the same device for all TFT LCD drivers.
Only one such driver can be configured in the kernel.
2015-10-10 16:48:32 -07:00
Serge Vakulenko
789505045c Add missing gpanel examples to the manifest file. 2015-10-09 22:36:35 -07:00
Serge Vakulenko
a78f66c220 Add two gpanel examples: color palette and speed test. 2015-10-09 17:44:46 -07:00
Serge Vakulenko
8b5e30f416 Add man page for gpanel library. 2015-10-09 15:05:02 -07:00
Serge Vakulenko
1d32cd012a Use rand() in gpanel examples. 2015-10-09 13:47:07 -07:00
Serge Vakulenko
d2fb9b98a6 Fix bug in hx8357: rasterizing glyphs with width>16. 2015-10-09 13:21:29 -07:00
Serge Vakulenko
08edaaba8c Fix bug in hxtft driver: drawing rectangles.
Add a few gpanel examples.
2015-10-08 22:15:01 -07:00
Serge Vakulenko
b99fcc6c8c Use GPANEL_CLEAR ioctl to switch the display orientation.
Enable gpio driver for Picadillo board.
2015-10-08 14:01:49 -07:00
Serge Vakulenko
f7d93551cb Fix bug in udelay(): incorrect CPU_KHZ multiply factor. 2015-10-08 12:30:34 -07:00
Serge Vakulenko
793e6052bd Add sysctl parameters to query the CPU and i/o bus frequency:
machdep.cpu_khz and machdep.bus_khz.
Fix bug in machdep.console_device parameter.
2015-10-08 11:34:20 -07:00
Serge Vakulenko
61cc452f1b TFT examples updated. 2015-10-06 19:02:00 -07:00
Serge Vakulenko
21c5beb7a6 Driver hx8357 enhanced to support gpanel ioctls. 2015-10-06 18:46:01 -07:00
Serge Vakulenko
20e1ad2cb2 Install libgpanel. 2015-10-06 13:20:59 -07:00
Serge Vakulenko
9831ddd3a8 Add gpanel library. 2015-10-06 13:15:39 -07:00
Serge Vakulenko
8f220cdf97 Move tft examples to a separate directory.
Add font files.
2015-10-05 18:47:42 -07:00
Serge Vakulenko
776dee30ea Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-10-03 14:26:29 -07:00
Serge Vakulenko
023f848428 New kernel option: signal "BUTTON1".
Hold this button pressed at kernel startup to enter a single-user mode.
See fubarino Config for example.
2015-10-03 14:24:17 -07:00
Serge Vakulenko
0f7e688c2e Add kernel configuration for SnadPIC MX795 board.
For board documentation, see:
http://www.microcontroller-board.com/snadpic-board-32/11-snadpic-pic32mx795f512l-development-board.html
2015-10-02 21:02:10 -07:00
Serge Vakulenko
3e439df5a2 Simplify spi_setup() function parameters. 2015-09-30 13:03:12 -07:00
Serge Vakulenko
e8e186905a Remove unused options from generic Config file. 2015-09-29 20:27:24 -07:00
Serge Vakulenko
d68b2f2dc1 Update spirams driver. 2015-09-29 20:23:53 -07:00
Serge Vakulenko
644b6c2112 Update mrams driver. 2015-09-29 19:43:33 -07:00
Serge Vakulenko
09112b6b7a Update sramc driver. 2015-09-29 18:45:48 -07:00
Serge Vakulenko
84a38361a5 Update sdramp driver for the new i/o framework. 2015-09-29 18:15:21 -07:00
Serge Vakulenko
c4cc4bc397 Fix bug in SD driver: incorrect size of partition. 2015-09-27 23:49:30 -07:00
Serge Vakulenko
4f7baefbf0 Build and install libm.a library.
Print a number of configured channels for adc and pwm drivers.
2015-09-27 13:59:50 -07:00
Serge Vakulenko
dc75784799 Cleanup in SD driver. 2015-09-26 23:32:12 -07:00
Serge Vakulenko
5cb608d7e1 Rename other disk drivers which needed rdisk.
Delete device names from all the drivers.
Move device inslude files from include/sys to include/machine directory.
Only include files which have something useful for user layer
(like special ioctls codes) should be placed into sys.
2015-09-26 23:00:13 -07:00
Serge Vakulenko
fdb295ec25 Create device files /dev/sdNx.
Delete unused flash driver.
2015-09-26 21:56:27 -07:00
Serge Vakulenko
3073e9af87 Modify SD driver for direct i/o (no rdisk). 2015-09-26 21:46:11 -07:00
Serge Vakulenko
1d0b58ab60 Allow comments in files.kconf. 2015-09-26 16:27:50 -07:00
Serge Vakulenko
5041402681 Add a few experimental ioctls to the hxtft driver. 2015-09-26 16:23:42 -07:00
Serge Vakulenko
1faf08d3ab Fix LEDs in makefiles for Fubarino and SDXL boards. 2015-09-25 20:33:22 -07:00
Serge Vakulenko
661929317c Enable spi3 and uart2 for Fubarino and SDXL boards. 2015-09-21 13:09:19 -07:00
Serge Vakulenko
3a4cc2d440 Update picga, mrams and spirams drivers. 2015-09-20 22:29:30 -07:00
Serge Vakulenko
80ab2d4721 Simplify the SPI driver. 2015-09-20 22:01:19 -07:00
Serge Vakulenko
a36504720c Update config files with new options. 2015-09-19 22:07:13 -07:00
Serge Vakulenko
4ca4a58468 For SD card, use parameters generated by kernel config utility. 2015-09-19 21:58:45 -07:00
Serge Vakulenko
9c749994c1 Setup only UARTs, defined in the kernel config file.
For console initialization, use options CONS_MAJOR and CONS_MINOR.
2015-09-19 21:23:07 -07:00
Serge Vakulenko
976bf303cc Kernel config utility: add new specification to assign
logical signals to pins. like 'signal "LED_KERNEL" pin RA0'.
2015-09-19 17:09:40 -07:00
Serge Vakulenko
bf92da35b8 Fix crash on access to gpio device. 2015-09-18 23:49:44 -07:00
Serge Vakulenko
f53ab56d1a Fix bug in assembler: incorrect alignment of rodata relocation section. 2015-09-17 22:11:36 -07:00
vak
51e09b4885 Fix bug in assembler: unaligned allocation of local common blocks. 2015-09-16 19:19:26 -07:00
vak
dbd2d74487 Fix bss size alignment in the assembler.
Relax the requirement in the linker as well.
2015-09-15 00:37:35 -07:00
Serge Vakulenko
3db23e5d6a Use flags for gpio driver to configure available pins. 2015-09-14 22:07:16 -07:00
Serge Vakulenko
c6360fb676 Use ioconf.c for device configuration. 2015-09-14 20:28:31 -07:00
Serge Vakulenko
51e46b333b Extend SmallerC sizes to be able to compile curses examples. 2015-09-14 11:48:16 -07:00
Serge Vakulenko
3dda877dfb Package readme file updated. 2015-09-14 11:42:51 -07:00
Serge Vakulenko
c9ed14824b Update package readme file (thanks Pito). 2015-09-14 11:21:49 -07:00
Serge Vakulenko
218466583d Fix curses bug: garbled output in nl mode.
Use nonl mode in sl, as more efficient.
2015-09-13 23:47:32 -07:00
Serge Vakulenko
7a8eff3fa3 Add a few curses examples. 2015-09-13 22:19:53 -07:00
Serge Vakulenko
261f70aef6 Enable nonl mode in libcurses by default.
Update sl sources from https://github.com/mtoyoda/sl.
2015-09-13 18:40:58 -07:00
Serge Vakulenko
2b09c13056 Use /root as a home for superuser.
Fix build warnings.
Delete extra copy of uuencode/uudecode.
2015-09-13 10:30:06 -07:00
Serge Vakulenko
3b1e8d40d7 Fix build errors. 2015-09-13 02:21:03 -07:00
Serge Vakulenko
0087168ba6 Add missing file /.profile.
Simplify stty utility, remove unused options.
2015-09-13 01:59:42 -07:00
Serge Vakulenko
967ec35fd2 Top level readme updated. 2015-09-08 23:40:38 -07:00
Serge Vakulenko
b906f7c2c5 Print SD select pin with R prefix, to match the datasheet. 2015-09-08 22:44:26 -07:00
Serge Vakulenko
0194d839ef Merge branch 'kconfig'. 2015-09-08 22:25:56 -07:00
Serge Vakulenko
b2806f3ad2 Merge branch 'master' into kconfig. 2015-09-08 22:22:29 -07:00
Serge Vakulenko
355ad339ef Kconfig: use named pins for SD select and enable signals. 2015-09-08 22:17:10 -07:00
Serge Vakulenko
c631ae5d43 Kconfig: generate xxx_ENABLED defines automatically. 2015-09-08 14:25:59 -07:00
Serge Vakulenko
717ab59efd Switch to kconfig completely.
All configsys stuff moved to tools/configsys/ directory, not used anymore.
2015-09-07 22:22:35 -07:00
Serge Vakulenko
9c8ee0a1a4 Merge branch 'master' of https://github.com/RetroBSD/retrobsd. 2015-09-07 21:32:55 -07:00
Serge Vakulenko
2c41b4d9e1 Fix crash in fsck, when reconnecting lost file. 2015-09-07 21:31:33 -07:00
Serge Vakulenko
3678ba6aee New configuration for MMB-MX7 board. 2015-09-07 17:13:10 -07:00
Serge Vakulenko
85300993b9 New configuration for Olimex Pinguino-Micro board. 2015-09-07 16:17:49 -07:00
Serge Vakulenko
137963240e New kernel configuration for SDXL board. 2015-09-07 16:12:00 -07:00
Serge Vakulenko
6facb3f56d New configurations for maximite and maximite-color boards. 2015-09-07 16:02:39 -07:00
Serge Vakulenko
bbaa00df52 New kernel configuration for starter kit board. 2015-09-07 15:46:13 -07:00
Serge Vakulenko
f17fa5a116 New kernel configuration for Explorer16 board. 2015-09-07 15:40:17 -07:00
Serge Vakulenko
ac83afdde8 New bare metal kernel configuration. 2015-09-07 15:30:41 -07:00
Serge Vakulenko
496e7ac168 New configuration for 32mxsdram board. 2015-09-05 16:18:02 -07:00
Serge Vakulenko
d7e7ae368d Delete unused file. 2015-09-04 21:26:21 -07:00
Serge Vakulenko
58359c0ff4 Rename 32mxsdram directory. 2015-09-04 21:03:54 -07:00
Serge Vakulenko
a73bd691b3 Simplify board names for max32 and wf32. 2015-09-04 20:55:02 -07:00
Serge Vakulenko
f055b45453 Kconfig: remove hz keyword. 2015-09-04 20:53:19 -07:00
Serge Vakulenko
9f05f511a6 Fixed issues with multiple kernel builds. 2015-09-04 18:55:56 -07:00
Serge Vakulenko
8ba13c2f71 Merge branch 'kconfig' of https://github.com/RetroBSD/retrobsd into kconfig. 2015-09-04 16:45:00 -07:00
Serge Vakulenko
fcad15f7e6 Generic config file updated. 2015-09-04 12:33:14 -07:00
Serge Vakulenko
5de76c3cf1 Remove MEB board. 2015-09-03 23:32:35 -07:00
Serge Vakulenko
a6396122f6 New configurations for Fubarino board.
Retroone configuration deleted.
2015-09-03 19:17:07 -07:00
Serge Vakulenko
d1eb7c79c2 New kernel configurations for UBW32 board. 2015-09-03 18:47:59 -07:00
Serge Vakulenko
095e957995 Create kernel configuration for Picadillo board. 2015-09-03 18:10:05 -07:00
Serge Vakulenko
8546991046 Fix retroone configuration.
Reorganize ubw32 and picadillo configurations.
2015-09-03 17:45:31 -07:00
Serge Vakulenko
328bdf4bbf Create kconfig configurations for Duinomite boards. 2015-09-03 17:15:50 -07:00
Serge Vakulenko
a302352054 Modify Makefile.kconf to generate dependency files automatically. 2015-09-03 13:05:37 -07:00
Serge Vakulenko
94c02410e4 Kconfig: rename machine to architecture, ident to board.
Make timezone and maxusers parameters optional.

Enable kernel options UCB_METER, EXEC_AOUT, EXEC_ELF and EXEC_SCRIPT
by default.
2015-09-03 12:51:56 -07:00
Serge Vakulenko
fc9d89eff2 Kconfig: use PARAM for all options. 2015-09-03 12:08:32 -07:00
Serge Vakulenko
23cafa1006 Merge branch 'kconfig' of https://github.com/RetroBSD/retrobsd into kconfig. 2015-09-03 11:44:14 -07:00
Serge Vakulenko
9f6a53122a Cleanup in kconfig files. 2015-09-03 11:44:03 -07:00
Serge Vakulenko
a8c229ed36 Create kconfig file for WF32 board. 2015-09-02 22:19:42 -07:00
Serge Vakulenko
592e2014fb Kconfig: remove unused options config-dependent, device-driver and profiling-routine.
Kernel makefile updated.
2015-09-02 18:19:30 -07:00
Serge Vakulenko
635d8ff2f7 GCC configuration script unified for both kconfig and configsys.
Ling scripts modified for compatibility with CodeScape toolchain.
Fixed gcc warnings in kernel and kconfig.
2015-09-01 19:46:57 -07:00
Serge Vakulenko
49de16b343 Fsutil enhanced to extract symlinks. 2015-08-31 18:35:37 -07:00
Serge Vakulenko
c19654daa9 Merge pull request #63 from alexfru/master
Smaller C: improve prologue on MIPS.
2015-08-31 00:26:49 -07:00
Serge Vakulenko
585773955b Fix include paths in the kernel sources.
Max32 kernel successfully compiled with kconfig utility.
2015-08-31 00:21:41 -07:00
Alexey Frunze
5f2b01ddda Smaller C: improve prologue on MIPS
Functions defined as 'type f()' now don't store A0-A3
on the stack just as functions defined as 'type f(void)'.
2015-08-30 23:52:26 -07:00
Serge Vakulenko
d80a636a62 Create generic kconfig script for pic32 platform. 2015-08-30 21:10:19 -07:00
Serge Vakulenko
0aaf6c25f6 Merge pull request #62 from alexfru/master
Smaller C: improvements.
2015-08-29 10:35:45 -07:00
Alexey Frunze
ae75f1cecc Smaller C: improvements
All architectures:
- "return" statement at function's end doesn't jump to immediately
  following epilog anymore
- zero and non-zero constants are recognized in conditional
  expressions of "if", "do/while" and "for" statements, no code
  generated to evaluate these constant conditions and related
  unnecessary jumps aren't generated anymore either
- in "for (clause-1; expr-2; expr-3) body", "expr-3" and "body" are
  now reordered to the more natural code flow "body expr-3", thereby
  getting rid of unnecessary jumps
MIPS code generator:
- function prologue/epilogue shortened further
- RA is not explicitly saved/restored in leaf functions
- assignment of 0 (e.g. "int a = 0;") is done from register 0
  directly, avoiding a load of a constant
2015-08-29 02:27:19 -07:00
Serge Vakulenko
c44239cb64 Bootloader moved to a separate GitHub repository. 2015-08-28 19:32:43 -07:00
Serge Vakulenko
4634b23849 Autobuild makefile updated. 2015-08-27 22:27:33 -07:00
Serge Vakulenko
2401afee53 Autobuild script updated. 2015-08-27 19:43:03 -07:00
Serge Vakulenko
09f3488389 Add pinguino-micro to the autobuild list. 2015-08-23 23:15:32 -07:00
Serge Vakulenko
b73411b3bd Autobuild script updated. 2015-08-23 22:48:02 -07:00
Serge Vakulenko
4bf3ca1292 Add autobuild script. 2015-08-23 22:45:16 -07:00
Serge Vakulenko
6419a655f4 Merge pull request #61 from alexfru/master
Smaller C: Recover ~7.5KB of data memory (room for improvements).
2015-08-22 22:19:08 -07:00
Alexey Frunze
531a56ed51 Smaller C: Recover ~7.5KB of data memory (room for improvements)
by splitting SyntaxStack[][] into two arrays and reducing
the size of the element of the first
2015-08-22 17:53:42 -07:00
Serge Vakulenko
aaaa3fd193 Autobuild makefile updated. 2015-08-22 01:42:39 -07:00
Serge Vakulenko
d6164dd82b Add tools/build directory. 2015-08-22 00:51:53 -07:00
Serge Vakulenko
00279386d7 Merge pull request #60 from alexfru/master
Update Smaller C.
2015-08-20 23:19:59 -07:00
Alexey Frunze
b331d3e0aa Update Smaller C
- Update license text (remove irrelevant FreeBSD references)

- Update root readme.txt

- Improve prologue/epilogue generation
  Don't generate unnecessary jumps back and forth to/from
  "sub sp, size_of_locals".
  Instead, with the help of fgetpos()/fsetpos()
  initially write ";sub sp,              0" and then, when
  the size is finally known, go back and overwrite it with
  " sub sp, size_of_locals".
2015-08-20 22:37:08 -07:00
Serge Vakulenko
c8939dc646 Fix bug in assembler: incorrect reordering of branch instruction.
Increase cpp buffer size.
2015-08-20 20:55:55 -07:00
Serge Vakulenko
c2a86d50bb Merge pull request #59 from ibara/master
Update to emg 1.8.
2015-08-19 13:51:00 -07:00
Brian Callahan
d29b887f18 Update to emg 1.8 2015-08-12 22:09:14 -04:00
Serge Vakulenko
f71ce9fc62 Pinguino-micro: kernel configuration updated. 2015-07-23 20:50:56 -07:00
vak
0a1960c864 Makefiles updated to properly build and install pdc and libreadline. 2015-07-18 21:44:58 -07:00
Serge Vakulenko
e8cb02f3f7 Added a tiny implementation of readline library, based on linenoise sources.
See https://github.com/antirez/linenoise for details.

Implemented a routine atexit() in libc.

Pdc modified to use readline library.
2015-07-18 18:41:46 -07:00
Serge Vakulenko
0b8e8bd520 Added pdc: the programmers desktop calculator,
imported from https://github.com/daniel-thompson/pdc repository.
2015-07-18 16:30:40 -07:00
Serge Vakulenko
84247c1ba5 Merge pull request #57 from daniel-thompson/groff
Add groff (which provides nroff) to the list of required packages.
2015-07-04 20:10:15 -07:00
vak
0c3fffb6f6 Merge pull request #56: Fix build for gcc >= 5.0.
gcc 5.0 defaults to -std=gnu11 meaning code which relies on implicit
ints will no longer compile. Passing -std=gnu89 restores the default
but causes problems because the system headers are written in gnu11.
Using -idirafter instead of -nostdinc resolves all problems and should
be compatible with old GCC versions (and clang).
2015-07-04 19:59:43 -07:00
Sergey
66cadb02a1 Fix uudecode.0 path in manifest. 2015-07-04 19:21:33 -07:00
Sergey
be7c8f804e Merge branch 'sinetek-uuencode'. 2015-07-04 19:14:42 -07:00
Sergey
af1147432a Merge branch 'uuencode' of https://github.com/sinetek/retrobsd into sinetek-uuencode 2015-07-04 19:14:06 -07:00
Serge Vakulenko
a9b2a816ba Merge pull request #54 from sinetek/fold
fold - sync with FreeBSD 2.0
2015-07-04 19:01:29 -07:00
Sergey
0329394f94 Add fold utility from FreeBSD 2.0. 2015-07-04 19:00:20 -07:00
Sergey
1bf595e11a Create $DESTDIR/share/calendar directory on install.
Also, added .gitignore for all new components.
2015-07-04 18:46:48 -07:00
Serge Vakulenko
455d7aeffe Merge pull request #53 from sinetek/calendar
calendar - sync with FreeBSD 2.0.
2015-07-04 16:46:52 -07:00
Serge Vakulenko
694c364cb4 Merge pull request #52 from sinetek/md5
md5 - sync with FreeBSD 2.0.
2015-07-04 16:44:58 -07:00
Serge Vakulenko
75470f1ac5 Merge pull request #51 from sinetek/master
Pull in a few games.
2015-07-04 16:41:23 -07:00
Daniel Thompson
804d646577 Add groff (which provides nroff) to the list of required packages.
debootstraped images will not have this by default.
2015-07-04 20:18:17 +01:00
sinetek
9623203f20 uuencode/uudecode - sync with FreeBSD 2.0 2015-07-03 16:54:18 +07:00
sinetek
8d061f04e3 fold - sync with FreeBSD 2.0 2015-07-03 16:35:12 +07:00
sinetek
49550e87d8 calendar - sync with FreeBSD 2.0 2015-07-03 16:07:55 +07:00
sinetek
6504a97fd1 md5 - sync with FreeBSD 2.0 2015-07-03 15:05:54 +07:00
sinetek
b81bb822f3 pig - sync with FreeBSD 2.0 2015-07-03 13:41:24 +07:00
sinetek
236fc62bb3 pom - sync with FreeBSD 2.0 2015-07-03 13:25:25 +07:00
sinetek
3890f0a6aa caesar - sync with FreeBSD 2.0 2015-07-03 13:12:25 +07:00
sinetek
24e057667e name clash with posix function 2015-07-03 10:09:29 +07:00
Serge Vakulenko
0cf79d71cf Added missing exception handler at startup.S. 2015-06-26 20:24:35 -07:00
Serge Vakulenko
229b664f35 Added kernel configuration for Olimex Pinguino-Micro board (with mx795 chip). 2015-06-26 14:08:59 -07:00
Serge Vakulenko
4c343f1525 Fixed bug in assembler: incorrect reordering. 2015-06-25 22:11:54 -07:00
Serge Vakulenko
219e2c3071 Fixed bug in rogue: incorrect use of NL for cursor positioning. 2015-06-24 22:45:33 -07:00
Serge Vakulenko
9d39282ae9 All paths moved to path.h.
Cleanup in curses.h: removed reg definition.
All include files reformatted for 4-space indent.
2015-06-24 20:57:08 -07:00
Serge Vakulenko
81a8a8379d Deleted unused include files dbm.h and pcc.h.
Deleted library functions stty() and gtty().
PicoC built in mips16 mode, without floating point support.
2015-06-24 19:19:46 -07:00
Serge Vakulenko
ea7c1415d7 Fixed declarations in include/time.h file.
Deleted unused file include/stab.h and reloc utility.
2015-06-24 17:45:47 -07:00
Serge Vakulenko
d1f1e614f0 Kernel sources reformated with 4 space indent, no tabs.
Unused file include/trace.h deleted.
2015-06-23 19:00:24 -07:00
Sergey
d9b3b93176 Fixed stack overflow in fsck. 2015-06-23 00:29:20 -07:00
Serge Vakulenko
880e6639ac All manual pages added to manifest file. 2015-06-22 22:44:18 -07:00
Serge Vakulenko
f462811ae9 Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-06-22 18:03:55 -07:00
Serge Vakulenko
664cc16008 Use devcfg.c files local per target directory. 2015-06-22 18:02:18 -07:00
Sergey
84445ee1f7 Fixed bug in fsutil, occasionally resulted in unexpected fsck errors.
It was caused by garbage at end of file names.
2015-06-21 20:00:36 -07:00
Sergey
bca590d42b Fixed issue #44.
Removed unnesessary include <sys/types.h> from stdio.h, stdlib.h,
string.h, strings.h and time.h.
2015-06-21 18:59:02 -07:00
Sergey
aedd0138b3 Fixed issue #46: broken instruction reordering in assembler. 2015-06-21 17:56:15 -07:00
Sergey
b028c7bb4b Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-06-21 17:05:29 -07:00
Sergey
57b3ba3506 Fixed .equ syntax in assembler. 2015-06-21 17:05:04 -07:00
Sergey
75778ddd4b Added configuration for version 2014.05 of Mentor Sourcery CodeBench Lite toolchain. 2015-06-13 19:57:11 -07:00
Sergey
76832ba217 Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-06-06 23:44:30 -07:00
Sergey
48de8a19bb LED cube examples modified for fubarino. 2015-06-06 23:43:26 -07:00
vak
21ddf7fa5a Kconfig updated. 2015-06-02 00:16:15 -07:00
Serge Vakulenko
1a5e0e40d9 Merge branch 'master' into kconfig. 2015-06-01 21:46:06 -07:00
Serge Vakulenko
428764c187 SD diag utility moved to tools.
Makefile for Retro 1 kernel modified to get rid of file drivers.mk.
2015-06-01 21:43:57 -07:00
Serge Vakulenko
ce8371152f Kconfig: fixed function declarations. 2015-06-01 19:48:56 -07:00
Serge Vakulenko
47988903ae Kconfig is able to parse max32 configuration script. 2015-06-01 19:14:27 -07:00
Serge Vakulenko
31caa114fe Kconfig: all outdated stuff removed. 2015-06-01 18:33:49 -07:00
Serge Vakulenko
ff81751188 Kconfig reindented to 4 spaces. 2015-06-01 17:58:14 -07:00
Serge Vakulenko
b72cfc52f9 Kconfig compiled clean. 2015-06-01 17:35:25 -07:00
Serge Vakulenko
c4e86a1a12 Sources of kernel config utility imported from LiteBSD. 2015-06-01 17:19:20 -07:00
Sergey
5f4ecde705 Fixed bug in cdevname(). 2015-05-30 19:26:12 -07:00
Sergey
f3ee6644b2 Create /var/cron directory at build time. 2015-05-30 19:07:40 -07:00
Sergey
6b3455956a Create all devices at build time. Don't call devupdate from /etc/rc
before fs check - it can ruin the filesysem.
2015-05-30 18:54:50 -07:00
Sergey
e08e51f1b9 Use permanent allocation of major indexes for character devices. 2015-05-30 18:28:22 -07:00
Sergey
a234dfc7dc Uart driver: on close, wait for output queue to drain. 2015-05-30 16:56:03 -07:00
Serge Vakulenko
f08aabff03 Merge pull request #48 from alexfru/master
fix libicache: sign-extend the immediate in SLTIU.
2015-05-30 15:31:48 -07:00
Alexey Frunze
ea88242733 Merge remote-tracking branch 'upstream/master' 2015-05-29 22:46:46 -07:00
Serge Vakulenko
4e8398cbc9 Driver oc renamed to pwm. 2015-05-29 20:41:26 -07:00
Serge Vakulenko
33fbb51528 Fubarino and Picadillo boards: spi and oc drivers enabled. 2015-05-29 20:14:17 -07:00
Serge Vakulenko
76df048700 Dhrystone: print dmips with better precision. 2015-05-29 16:34:46 -07:00
Serge Vakulenko
d10b71a307 Dhrystone benchmark added to /share/examples. 2015-05-29 13:39:00 -07:00
Alexey Frunze
51f41b2cca fix libicache: sign-extend the immediate in SLTIU 2015-05-28 06:40:02 -07:00
Sergey
fcf0f3dad2 Fixed Makefile (led7) for sensors examples. 2015-05-24 00:10:05 -07:00
Serge Vakulenko
e949850567 Merge pull request #47 from alexfru/master
Smaller C: Improve initialization of variables
2015-05-23 01:50:17 -07:00
Alexey Frunze
3afa8e5979 Smaller C: Improve initialization of variables
- throw away data of string literals inside sizeof, e.g.
    sizeof "a"
    sizeof("a"+1)
- support minimally and inconsistently bracketed (sic)
  initialization, e.g.:
    int y[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 };
    struct { int a[3], b; } w[] = { { 1 }, 2 };
- scalar initializers can be optionally enclosed in
  braces, e.g.:
    int i1 = { 1 };
2015-05-23 01:15:52 -07:00
Serge Vakulenko
976d84d56d Merge pull request #45 from alexfru/master
Smaller C improvements.
2015-05-19 20:50:40 -07:00
Serge Vakulenko
d5599ae63a Led6 example fixed. 2015-05-19 20:47:30 -07:00
Serge Vakulenko
0c22adf6bf Added example for 6-digit LCD display. 2015-05-19 17:35:41 -07:00
Sergey
7590783d92 Added demos for LED cube 8x8x8. 2015-05-17 22:39:30 -07:00
Alexey Frunze
6144631bc5 Smaller C: Support structure passing/returning by value on MIPS 2015-05-17 15:28:37 -07:00
Alexey Frunze
4ea521eabf Smaller C improvements
- type specifiers may occur in any order
  (e.g. "unsigned short int" and "int short unsigned")

- use .rodata/.rdata section for string literals
- arbitrary length string literals (hooray!)
- better concatenation of adjacent string literals
  (now works even across preprocessor directives)

Support .bss section
- -nobss option in smlrc: use .data instead of .bss as before
- take advantage of .bss in smlrc (put a large array into it)

Remove dead/useless code

Remove useless/rarely used features/options:
-use-gp (MIPS)
-flat16/-flat32 (x86)
-seg16t (x86), -seg16 is now the default
-ctor-fxn

Add/change:
- use EXIT_FAILURE=1 instead of -1 in smlrc when aborting
  due to an error
2015-05-16 05:57:39 -07:00
Serge Vakulenko
352d23a073 Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-05-15 22:59:54 -07:00
Serge Vakulenko
c054a40805 Fixed bug in tetris. 2015-05-15 22:59:16 -07:00
Serge Vakulenko
23f426ded5 Tetris example modified for cc compatibility. 2015-05-15 22:22:44 -07:00
Serge Vakulenko
bf27d6d5c3 Added tetris and joystick examples. 2015-05-15 22:12:01 -07:00
Sergey
c40136c25d Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2015-05-14 22:52:27 -07:00
Serge Vakulenko
ea03a4bc98 ADM demo rewritten without curses.
Examples reorganized.
Added examples for 37-in-1 sensor kit (not complete yet).
2015-05-14 22:11:47 -07:00
Serge Vakulenko
581ab61262 Fixed bug in gpio driver: /dev/confX device not able to configure the pin mask. 2015-05-14 12:38:04 -07:00
Sergey
f2fe94f32d Register dump fixed. 2015-05-08 22:18:10 -07:00
Serge Vakulenko
ff4a186025 Merge pull request #43 from alexfru/master
Fix issue #40.
2015-04-26 00:22:10 -07:00
Alexey Frunze
d95f161319 Merge remote-tracking branch 'upstream/master' 2015-04-25 20:05:13 -07:00
alex
a20c02c11f Fix issue #40. Properly flush stdio's streams at exit. 2015-04-25 19:49:26 -07:00
Serge Vakulenko
e5e44bfb94 Merge pull request #42 from alexfru/master
Smaller C fixes.
2015-04-25 18:12:46 -07:00
alex
acd1b5da26 Merge branch 'master' of https://github.com/alexfru/retrobsd 2015-04-25 18:05:44 -07:00
alex
a4bdbd4662 Bugfixes
- properly sign-/zero-extend returned values, e.g. the following
function must return 255 and not -1:

unsigned char f(void) { return -1; }

- properly decay arrays on the left side of ->, e.g. the following must
compile:

{
  struct {char c;} s[1];
  s[0].c = 'a'; putchar(s[0].c);
  (s+0)->c = 'b'; putchar(s[0].c);
  (*s).c = 'c'; putchar(s[0].c);
  s->c = 'd'; putchar(s[0].c);
  putchar('\n');
}

Also:
- support structure passing/returning by value (x86 only)
2015-04-25 18:03:55 -07:00
alex
301d069a1a Bugfixes
- properly sign-/zero-extend returned values, e.g. the following
function must return 255 and not -1:

unsigned char f(void) { return -1; }

- properly decay arrays on the left side of ->, e.g. the following must
compile:

{
  struct {char c;} s[1];
  s[0].c = 'a'; putchar(s[0].c);
  (s+0)->c = 'b'; putchar(s[0].c);
  (*s).c = 'c'; putchar(s[0].c);
  s->c = 'd'; putchar(s[0].c);
  putchar('\n');
}
2015-04-25 17:54:17 -07:00
Sergey
9bbe938e48 At startup, set peripheral clock PBCLK as defined by busdiv option
in kernel configuration file.
2015-02-14 20:20:19 -08:00
Sergey
d5c97a9b19 Added bit definitions for OSCCON register.
File machdep.c reindented.
2015-02-14 17:57:48 -08:00
Sergey
0005e7d7bf Fixed bug in fsck: using bcopy() instead of structure assignment.
File exception.c converted to indent4 format.
2015-02-13 21:05:03 -08:00
Sergey
42665ba3b3 SPI bus driver simplified. 2015-02-13 19:48:32 -08:00
Sergey
942bdda5ed Diskspeed: added extra sync and timeout before each test. 2015-02-13 19:41:32 -08:00
Serge Vakulenko
5ce8a8cd33 Added diskspeed utility. 2015-02-12 19:27:59 -08:00
Serge Vakulenko
b3442f28f3 Finalize skel.h. 2015-02-05 19:12:50 -08:00
Serge Vakulenko
29c75b3f71 Skeleton driver completed. 2015-02-05 19:08:53 -08:00
Serge Vakulenko
9b9f6392dc Added a skeleton for character driver. 2015-02-05 19:05:59 -08:00
Serge Vakulenko
f5bbefc222 Fixed indenting in devsw.c. 2015-02-05 18:13:17 -08:00
Serge Vakulenko
7f5ad5d3f8 Using Max32 board with Arduino SD card shield as a default configuration. 2015-02-04 14:28:03 -08:00
Serge Vakulenko
df8f8eaf71 Directory sys/pic32/max32 removed: nobody is using this configuration,
as it required a nonstandard SD card connection.
2015-02-04 14:18:42 -08:00
Serge Vakulenko
f62f70c718 Max32-eth configuration: SD card speed reduced to 10MHz.
Now it works stable with MakerStudio SD card shield.
2015-02-02 22:26:19 -08:00
Serge Vakulenko
1916f8c9da New kernel configuration: chipKIT WF32 board with microSD card on 2.4" LCD TFT display shield.
WF32 board by itself already has a microSD socket.
It's useless for RetroBSD though, as it is not connected to any
of available SPI ports (must use GPIO instead).

Fortunately, a cheap shield is widely available, which adds a microSD slot
connected to SPI2 pins.
2015-01-28 19:14:41 -08:00
Serge Vakulenko
d8269d1996 No more pause on tty output in case of clist overflow. 2015-01-20 18:09:13 -08:00
Serge Vakulenko
8e228dde62 Fixed bug in fsutil: incorrect positioning of partition superblock. 2015-01-06 19:47:31 -08:00
Serge Vakulenko
bae12383a0 Fixed build issues on Linux x86-64. 2015-01-06 19:36:49 -08:00
1414 changed files with 175588 additions and 63660 deletions

3
.gitignore vendored
View File

@@ -24,7 +24,6 @@
*.dis
*.0
*.img
sdcard.rd
.profile
Makefile.user
TODO

View File

@@ -8,32 +8,6 @@
# The `make' will compile everything, including a kernel, utilities
# and a root filesystem image.
#
# Supported boards
#
MAX32 = sys/pic32/max32/MAX32
MAX32-ETH = sys/pic32/max32-eth/MAX32-ETH
UBW32 = sys/pic32/ubw32/UBW32
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM
MAXIMITE = sys/pic32/maximite/MAXIMITE
MAXCOLOR = sys/pic32/maximite-color/MAXCOLOR
EXPLORER16 = sys/pic32/explorer16/EXPLORER16
STARTERKIT = sys/pic32/starter-kit/STARTER-KIT
DUINOMITE = sys/pic32/duinomite/DUINOMITE
DUINOMITEUART = sys/pic32/duinomite-uart/DUINOMITE-UART
DUINOMITEE = sys/pic32/duinomite-e/DUINOMITE-E
DUINOMITEEUART = sys/pic32/duinomite-e-uart/DUINOMITE-E-UART
BAREMETAL = sys/pic32/baremetal/BAREMETAL
RETROONE = sys/pic32/retroone/RETROONE
FUBARINO = sys/pic32/fubarino/FUBARINO
FUBARINOBIG = sys/pic32/fubarino/FUBARINO-UART2CONS-UART1-SRAMC
SDXL = sys/pic32/sdxl/SDXL
MMBMX7 = sys/pic32/mmb-mx7/MMB-MX7
# Select target board
TARGET ?= $(MAX32)
# Filesystem and swap sizes.
FS_MBYTES = 100
U_MBYTES = 100
@@ -55,23 +29,19 @@ FSUTIL = tools/fsutil/fsutil
-include Makefile.user
TARGETDIR = $(shell dirname $(TARGET))
TARGETNAME = $(shell basename $(TARGET))
TOPSRC = $(shell pwd)
CONFIG = $(TOPSRC)/tools/configsys/config
all: .profile
all:
$(MAKE) -C tools
$(MAKE) -C src
$(MAKE) -C lib
$(MAKE) -C src install
$(MAKE) -C install
$(MAKE) kernel
$(MAKE) fs
kernel: $(TARGETDIR)/Makefile
$(MAKE) -C $(TARGETDIR)
$(TARGETDIR)/Makefile: $(CONFIG) $(TARGETDIR)/$(TARGETNAME)
cd $(TARGETDIR) && ../../../tools/configsys/config $(TARGETNAME)
kernel: $(CONFIG)
$(MAKE) -C sys/pic32 all
fs: sdcard.img
@@ -80,7 +50,9 @@ sdcard.img: $(FSUTIL) rootfs.manifest userfs.manifest
rm -f $@
$(FSUTIL) --repartition=fs=$(FS_MBYTES)M:swap=$(SWAP_MBYTES)M:fs=$(U_MBYTES)M $@
$(FSUTIL) --new --partition=1 --manifest=rootfs.manifest $@ .
$(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u
# In case you need a separate /u partition,
# uncomment the following line.
# $(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u
$(FSUTIL):
cd tools/fsutil; $(MAKE)
@@ -100,7 +72,7 @@ cleanall: clean
rm -f share/re.help share/emg.keys share/misc/more.help
rm -f etc/termcap etc/remote etc/phones
rm -f tools/configsys/.depend
rm -f var/log/aculog
rm -f var/log/aculog sdcard.img
rm -rf var/lock share/unixbench
installfs:
@@ -118,6 +90,3 @@ installflash:
# TODO: make it relative to Target
installboot:
sudo pic32prog sys/pic32/fubarino/bootloader.hex
.profile: etc/root/dot.profile
cp etc/root/dot.profile .profile

View File

@@ -15,55 +15,35 @@
## Supported hardware
* chipKIT Max32 board.
* Sparkfun UBW32 board.
* Fubarino SD board.
* Olimex Duinomite, Duinomite-Mini, Duinomite-Mega and Duinomite-eMega boards.
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
* Maximite and Colour Maximite computers.
* Majenko SDXL board.
* 4D Systems Picadillo-35T board.
* MikroElektronika MultiMedia Board for PIC32MX7.
* chipKIT Max32 board with SD card shield.
* chipKIT WF32 board with 2.4" LCD TFT display shield.
* Sparkfun UBW32 board with SD card slot.
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
* eflightworks DIP board.
## Build
To compile everything from sources, you'll need some packages installed, namely:
Berkeley YACC, GNU bison and flex, ELF library and FUSE library.
Berkeley YACC, GNU bison, flex, groff, ELF library and FUSE library.
Under Ubuntu, for example, you can do it by command:
```shell
$ sudo apt-get install bison byacc flex libelf-dev libfuse-dev
$ sudo apt-get install bison byacc flex groff-base libelf-dev
```
By default, the system is configured for the Max32 board.
To select another target board, edit a top-level user-specific Makefile called "Makefile.user"
and set a TARGET value:
You can change a desired filesystem size and swap area size, as required.
Default is:
```Makefile
TARGET = $(UBW32) # for the UBW32 board with USB console
TARGET = $(UBW32UART) # for the UBW32 board with UART console
TARGET = $(UBW32UARTSDRAM) # for the UBW32 boars with UART console and 8MB SRAM ramdisk
TARGET = $(MAXIMITE) # for the Maximite board
TARGET = $(MAXCOLOR) # for the Colour Maximite board
TARGET = $(EXPLORER16) # for the Explorer 16 board
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
TARGET = $(MAX32) # default
TARGET = $(MAX32-ETH) # for the chipKIT MAX32 board with Arduino Ethernet shield
TARGET = $(DUINOMITE) # for the Duinomite board with USB console
TARGET = $(DUINOMITEUART) # for the Duinomite board with UART console
TARGET = $(DUINOMITEE) # for the Duinomite E board with USB console
TARGET = $(DUINOMITEEUART) # for the Duinomite E board with UART console
TARGET = $(BAREMETAL) # Bare PIC32 chip on a breakout board
TARGET = $(FUBARINO) # Fubarino SD board
TARGET = $(FUBARINOBIG) # Fubarino SD board with 8MB SRAM RAMDISK
TARGET = $(MMBMX7) # MMB MX7 board
```
You can also change a desired filesystem size and swap area size,
as required. Default is:
```Makefile
FS_KBYTES = 16384
SWAP_KBYTES = 2048
FS_MBYTES = 100
SWAP_MBYTES = 2
```
To compile the kernel and build a filesystem image, run:
@@ -94,11 +74,11 @@ Kernel image should be written to PIC32 flash memory. The procedure depends
on a board used.
#### Max32 board:
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
and a USB cable to install a kernel:
```shell
$ cd sys/pic32/ubw32
$ AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
$ pic32prog -d /dev/ttyUSB0 sys/pic32/max32/unix.hex
```
Here you need to change AVRTOOLS path and tty name according to your system.

View File

@@ -23,9 +23,13 @@ LDFLAGS =
LIBS =
# Add system include path
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
CFLAGS += -I/usr/include
ifeq (/usr/include/x86_64-linux-gnu,$(wildcard /usr/include/x86_64-linux-gnu))
CFLAGS += -I/usr/include/x86_64-linux-gnu
else
ifeq (/usr/include/i386-linux-gnu,$(wildcard /usr/include/i386-linux-gnu))
CFLAGS += -I/usr/include/i386-linux-gnu
else
CFLAGS += -I/usr/include
endif
endif
CFLAGS += -I$(TOPSRC)/include

1
etc/.gitignore vendored
View File

@@ -1,3 +1,4 @@
localtime
phones
remote
termcap

View File

@@ -4,46 +4,14 @@
# All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
# @(#)MAKEDEV 4.27.6 (2.11BSD) 1999/2/19
#
# Device "make" file. Valid arguments:
# std standard devices
# local configuration specific devices
# fd file descriptor driver
# Tapes:
# ht* unibus tu77 & te16
# tm* unibus tm11 & te10 emulations (e.g. Emulex tc-11)
# ts* unibus ts11
# tu* tmscp (tk50/tu81)
# Disks:
# br* unibus Eaton br1538 or br1711
# hk* unibus rk06 and rk07
# ra* unibus uda50 w/ ra??
# rk* unibus rk05
# rl* unibus rl01/rl02
# rx* unibus rx02
# si* unibus cdc 9766 w/ si 9500
# xp* unibus rm02/03/05, rp04/05/06, diva, eagle, cdc9766, fuji 160.
# Terminal multiplexors:
# dl* dl-11 units other than the console
# dz* unibus dz11 and dz32
# dh* unibus dh11 and emulations (e.g. Able dmax, Emulex cs-11)
# dmf* unibus dmf32
# dhu* unibus dhu11
# dmz* unibus dmz32
# dhv* qbus dhv11
# sd* flash cards SecureDigital
# Pseudo terminals:
# pty* set of 16 master and slave pseudo terminals
# Printers:
# lp* unibus lp11 parallel interface
# va* unibus varian parallel interface
# vp* unibus versatec parallel interface
# Call units:
# Special purpose devices:
# dr* unibus dr11
# ram* memory disk
# dn* dn11 dialer
# ingreslock Ingres lock driver.
PATH=/etc:/sbin:/usr/sbin:/bin:/usr/bin
umask 77

View File

@@ -11,7 +11,6 @@ DESTDIR = /foobar
OWN = root
GRP = wheel
SUBDIR = root
FILES = crontab fstab gettytab group motd passwd \
rc rc.local shells syslog.conf ttys
@@ -19,8 +18,6 @@ all install depend lint tags:
clean:
rm -f *~
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} $@); done
distribution:
-@mkdir -p ${DESTDIR}/dev
@@ -75,5 +72,3 @@ distribution:
${DESTDIR}/usr/adm/savacct
install -c -o uucp -g daemon -m 600 /dev/null \
${DESTDIR}/usr/adm/aculog
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} distribution); done

View File

@@ -1,2 +1,2 @@
/dev/rd0a / ufs rw,async 1 1
#/dev/rd0c /u ufs rw,async 1 2
/dev/sd0a / ufs rw,async 1 1
#/dev/sd0c /u ufs rw,async 1 2

View File

@@ -1,8 +1,7 @@
root:5:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/:/bin/sh
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 &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/:/bin/csh
operator:*:2:5:System &:/u/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:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico

2
etc/rc
View File

@@ -3,8 +3,6 @@ HOME=/; export HOME
PATH=/bin:/sbin; export PATH
exec >/dev/console 2>&1
/sbin/devupdate
if test "$1" != "autoboot"; then
#
# Switch from single-user to multi-user mode.

View File

@@ -1,18 +0,0 @@
#
# 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.
DESTDIR = /foobar
OWN = root
GRP = wheel
all install depend lint tags:
distribution:
install -c -o ${OWN} -g ${GRP} -m 644 dot.cshrc ${DESTDIR}/.cshrc
install -c -o ${OWN} -g ${GRP} -m 644 dot.login ${DESTDIR}/.login
install -c -o ${OWN} -g ${GRP} -m 644 dot.profile ${DESTDIR}/.profile
clean:
rm -f *~

View File

@@ -1,14 +0,0 @@
set history=30
set path=(/bin /sbin /etc /usr/sbin /usr/ucb /usr/bin /usr/new /usr/local)
if ($?prompt) then
set prompt="\!% "
endif
set filec
set mail=( 0 /usr/spool/mail/$USER )
set cdpath=( ~ /usr/spool/mqueue)
set prompt="\!% root--> "
alias mail /usr/ucb/Mail
alias pwd 'echo $cwd'
alias h history
alias q5 'tail -5 /usr/spool/mqueue/syslog'

View File

@@ -1,14 +0,0 @@
unset noglob
set path=(/bin /etc /sbin /usr/sbin /usr/ucb /usr/bin /usr/local /usr/new)
umask 26
stty dec erase ^H kill ^U eof ^D
set prompt="[\!] root--> "
if ( "$TERM" == dialup || "$TERM" == network) then
setenv TERM vt100
echo -n "Terminal ($TERM)? "
set argv = "$<"
if ( "$argv" != '' ) setenv TERM "$argv"
endif
biff y

View File

@@ -1,8 +0,0 @@
echo 'erase, kill ^U, intr ^C'
stty dec
stty erase
PATH=/bin:/sbin:/usr/sbin:/etc:/usr/ucb:/usr/bin:/usr/new
export PATH
HOME=/
export HOME
export TERM

View File

@@ -1,8 +1,7 @@
root:ro46DZg1ViGBs:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/:/bin/sh
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 &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/:/bin/csh
operator:*:2:5:System &:/u/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:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico

1
include/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
readline

View File

@@ -1,5 +1,3 @@
/* assert.h 4.2 85/01/21 */
# 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)

View File

@@ -1,5 +1,3 @@
/* ctype.h 4.2 85/09/04 */
#define _U 01
#define _L 02
#define _N 04

View File

@@ -10,7 +10,6 @@
#include <term.h>
#define bool int
#define reg register
#define TRUE (1)
#define FALSE (0)
@@ -33,7 +32,6 @@ 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,
@@ -86,17 +84,17 @@ extern WINDOW *stdscr, *curscr;
int __void__;
#define VOID(x) (__void__ = (int) (x))
#else
#define VOID(x) (x)
#define VOID(x) ((void)(x))
#endif
/*
* psuedo functions for standard screen
*/
#define addch(ch) VOID(waddch(stdscr, ch))
#define getch() VOID(wgetch(stdscr))
#define getch() 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 move(y, x) wmove(stdscr, y, x)
#define clear() VOID(wclear(stdscr))
#define erase() VOID(werase(stdscr))
#define clrtobot() VOID(wclrtobot(stdscr))
@@ -113,7 +111,7 @@ int __void__;
/*
* mv functions
*/
#define mvwaddch(win,y,x,ch) VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
#define mvwaddch(win,y,x,ch) (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))
@@ -131,7 +129,6 @@ int __void__;
/*
* psuedo functions
*/
#define clearok(win,bf) (win->_clear = bf)
#define leaveok(win,bf) (win->_leave = bf)
#define scrollok(win,bf) (win->_scroll = bf)

View File

@@ -1,28 +0,0 @@
/*
* 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.h 5.1 (Berkeley) 3/27/86
*/
#ifndef NULL
/*
* this is lunacy, we no longer use it (and never should have
* unconditionally defined it), but, this whole file is for
* backwards compatability - someone may rely on this.
*/
#define NULL ((char *) 0)
#endif
#include <ndbm.h>
datum fetch();
datum firstkey();
datum nextkey();
#if 0
datum makdatum();
datum firsthash();
long calchash();
long hashinc();
#endif

View File

@@ -47,9 +47,6 @@
* if type is "rq", then use concatenation of fs_file and "quotas" to locate
* quota file.
*/
#define _PATH_FSTAB "/etc/fstab"
#define FSTAB "/etc/fstab" /* deprecated */
#define FSTAB_RW "rw" /* read/write device */
#define FSTAB_RQ "rq" /* read/write with quotas */
#define FSTAB_RO "ro" /* read-only device */

View File

@@ -13,3 +13,5 @@ struct group *getgrgid(gid_t gid);
void setgrent(void);
void endgrent(void);
int setgroups(size_t size, const gid_t *list);
int getgrouplist(char *uname, gid_t agroup, gid_t *groups, int *grpcnt);
int initgroups(char *uname, int agroup);

2
include/inttypes.h Normal file
View File

@@ -0,0 +1,2 @@
#include <stdint.h>
#include <stddef.h>

View File

@@ -36,36 +36,6 @@
#ifndef _LIMITS_H_
#define _LIMITS_H_
/*
* We don't need this crud at the moment so save on abuse of the C
* preprocessor by not doing the defines.
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 6
#define _POSIX_LINK_MAX 8
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_OPEN_MAX 16
#define _POSIX_PATH_MAX 255
#define _POSIX_PIPE_BUF 512
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_TZNAME_MAX 3
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_EQUIV_CLASS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
*/
#include <machine/limits.h>
/* #include <sys/syslimits.h> */
#endif /* !_LIMITS_H_ */

View File

@@ -4,16 +4,16 @@
* specifies the terms and conditions for redistribution.
*/
extern double fabs(), floor(), ceil(), fmod(), ldexp();
extern double sqrt(), hypot(), atof();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double exp(), log(), log10(), pow();
extern double sinh(), cosh(), tanh();
extern double gamma();
extern double j0(), j1(), jn(), y0(), y1(), yn();
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 1.701411733192644270e38
#define LOGHUGE 39
#define HUGE_VAL 3.40282347e+38 /* TBD??? use infinity? */
int isnanf(float x);
int isnan(double x);
@@ -31,3 +31,21 @@ 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 */

View File

@@ -10,11 +10,7 @@
* Hashed key data base library.
*/
#define PBLKSIZ 1024
#ifdef pdp11
#define DBLKSIZ 512
#else
#define DBLKSIZ 4096
#endif
#define DBLKSIZ 1024
typedef struct {
int dbm_dirf; /* open directory file */

View File

@@ -39,7 +39,7 @@
*/
struct nlist {
char *n_name; /* In memory address of symbol name,
or string table offset (file) */
* 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 */

View File

@@ -24,18 +24,25 @@
#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 "/lib/"
#define _PATH_CTIMED "/libexec/ctimed"
#define _PATH_LOCALLIB "/local/lib/"
#define _PATH_SBIN "/sbin/"
#define _PATH_USRSBIN "/sbin/"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_SENDMAIL "/sbin/sendmail"
#define _PATH_SHARE "/share/"
#define _PATH_ZONEINFO "/share/zoneinfo" /* Time zone object file directory */

View File

@@ -1,229 +0,0 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)pcc.h 5.1 (Berkeley) 5/30/85
*/
/*
* This file contains definitions for all the constants and structures
* needed to use the intermediate code files generated and read by
* the Portable C Compiler and related compilers.
*
* Rules for changing this code:
* 1) All op values must be integer constants -- this permits us to run
* a 'sed' script on this file to create %term declarations for yacc.
* 2) Because the PCC uses fancy ASG and UNARY macros, assignment
* operators must have values 1 greater than corresponding normal
* operators, and unary operators must have values 2 greater ditto.
* 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS).
* 4) Other language-dependent ops must have values >= 200.
*/
# ifndef PCC_TOKENS
# define PCC_TOKENS 0
# define PCC_ERROR 1 /* an error node */
# define PCC_FREE 2 /* an unused node */
/*
* Constants.
*/
# define PCC_STRING 3 /* a string constant */
# define PCC_ICON 4 /* an integer constant */
# define PCC_FCON 5 /* a floating point constant */
# define PCC_DCON 6 /* a double precision f.p. constant */
/*
* Leaf types.
*/
# define PCC_NAME 7 /* an identifier */
# define PCC_REG 8 /* a register */
# define PCC_OREG 9 /* register and offset */
# define PCC_CCODES 10 /* condition codes */
# define PCC_FLD 11 /* a bit field */
/*
* Arithmetic operators.
*/
# define PCC_PLUS 12 /* + */
# define PCC_PLUSEQ 13 /* += */
# define PCC_UPLUS 14 /* unary + (for completeness) */
# define PCC_MINUS 15 /* - */
# define PCC_MINUSEQ 16 /* -= */
# define PCC_UMINUS 17 /* unary - */
# define PCC_MUL 18 /* * */
# define PCC_MULEQ 19 /* *= */
/* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */
# define PCC_DIV 21 /* / */
# define PCC_DIVEQ 22 /* /= */
# define PCC_MOD 23 /* % */
# define PCC_MODEQ 24 /* %= */
# define PCC_INCR 25 /* ++ */
# define PCC_DECR 26 /* -- */
# define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */
/*
* Bit operators.
*/
# define PCC_AND 28 /* & */
# define PCC_ANDEQ 29 /* &= */
/* Reserve a slot for 'unary &', jargon for PCC_ADDROF */
# define PCC_OR 31 /* | */
# define PCC_OREQ 32 /* |= */
# define PCC_ER 33 /* ^ */
# define PCC_EREQ 34 /* ^= */
# define PCC_LS 35 /* << */
# define PCC_LSEQ 36 /* <<= */
# define PCC_RS 37 /* >> */
# define PCC_RSEQ 38 /* >>= */
# define PCC_COMPL 39 /* ~ */
/*
* Booleans.
*/
# define PCC_EQ 40 /* == */
# define PCC_NE 41 /* != */
# define PCC_LE 42 /* <= */
# define PCC_LT 43 /* < */
# define PCC_GE 44 /* >= */
# define PCC_GT 45 /* > */
# define PCC_ULE 46 /* unsigned <= */
# define PCC_ULT 47 /* unsigned < */
# define PCC_UGE 48 /* unsigned >= */
# define PCC_UGT 49 /* unsigned > */
# define PCC_QUEST 50 /* ? (for conditional expressions) */
# define PCC_COLON 51 /* : (for conditional expressions) */
# define PCC_ANDAND 52 /* && */
# define PCC_OROR 53 /* || */
# define PCC_NOT 54 /* ! */
/*
* Function calls.
*/
# define PCC_CALL 55 /* call by value */
/* no ASG */
# define PCC_UCALL 57 /* call with no arguments */
# define PCC_FORTCALL 58 /* call by reference? */
/* no ASG */
# define PCC_UFORTCALL 60 /* ??? */
# ifdef INLINE
# define PCC_INLINE 61 /* inline function */
/* no ASG */
# define PCC_UINLINE 63 /* inline with no arguments */
# endif INLINE
/*
* Referencing and dereferencing.
*/
# define PCC_DEREF 20 /* * */
# define PCC_ADDROF 30 /* & */
/*
* Special structure operators.
*/
# define PCC_DOT 64 /* . */
# define PCC_STREF 65 /* -> */
# define PCC_STASG 66 /* structure assignment */
# define PCC_STARG 67 /* an argument of type structure */
# define PCC_STCALL 68 /* a function of type structure */
/* no ASG */
# define PCC_USTCALL 70 /* unary structure function */
/*
* Conversions.
*/
# define PCC_SCONV 71 /* scalar conversion */
# define PCC_PCONV 72 /* pointer conversion */
# define PCC_PMCONV 73 /* pointer multiply conversion */
# define PCC_PVCONV 74 /* pointer divide conversion */
# define PCC_CAST 75 /* redundant? */
/*
* Bracket types.
*/
# define PCC_LB 76 /* [ */
# define PCC_RB 77 /* ] */
/*
* Comma nodes.
*/
# define PCC_COMOP 78 /* , (in expressions) */
# define PCC_CM 79 /* , (in argument lists) */
/*
* Miscellaneous.
*/
# define PCC_FORCE 80 /* result of last expression goes in r0 */
# define PCC_GOTO 81 /* unconditional goto */
# define PCC_CBRANCH 82 /* goto label if !test */
# define PCC_RETURN 83 /* return from function */
# define PCC_INIT 84 /* initialized data */
# define PCC_TYPE 85 /* a type */
# define PCC_CLASS 86 /* a storage class */
# define PCC_MAXOP 86 /* highest numbered PCC op */
/*
* Special codes for interfacing to /lib/f1.
*/
# define PCCF_FORTOPS 150
# define PCCF_FTEXT 150 /* pass literal assembler text */
# define PCCF_FEXPR 151 /* a statement */
# define PCCF_FSWITCH 152 /* not implemented */
# define PCCF_FLBRAC 153 /* beginning of subroutine */
# define PCCF_FRBRAC 154 /* end of subroutine */
# define PCCF_FEOF 155 /* end of file */
# define PCCF_FARIF 156 /* not implemented */
# define PCCF_FLABEL 157 /* an f77 label */
# endif PCC_TOKENS
/*
* Types, as encoded in intermediate file cookies.
*/
# define PCCT_UNDEF 0
# define PCCT_FARG 1 /* function argument */
# define PCCT_CHAR 2
# define PCCT_SHORT 3
# define PCCT_INT 4
# define PCCT_LONG 5
# define PCCT_FLOAT 6
# define PCCT_DOUBLE 7
# define PCCT_STRTY 8
# define PCCT_UNIONTY 9
# define PCCT_ENUMTY 10
# define PCCT_MOETY 11 /* member of enum */
# define PCCT_UCHAR 12
# define PCCT_USHORT 13
# define PCCT_UNSIGNED 14
# define PCCT_ULONG 15
/*
* Type modifiers.
*/
# define PCCTM_PTR 020
# define PCCTM_FTN 040
# define PCCTM_ARY 060
# define PCCTM_BASETYPE 017
# define PCCTM_TYPESHIFT 2
/*
* Useful macros. 'PCCOM' macros apply to ops.
*/
# define PCCOM_ASG 1+
# define PCCOM_UNARY 2+
# define PCCOM_NOASG (-1)+
# define PCCOM_NOUNARY (-2)+
# define PCCM_TRIPLE(op, var, type) \
((op) | ((var) << 8) | (long) (type) << 16)
# define PCCM_TEXT(s) \
PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0)
# define PCCM_ADDTYPE(t, m) \
((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \
(m) | ((t) & PCCTM_BASETYPE))

View File

@@ -34,7 +34,7 @@ struct psout {
time_t o_cstime; /* u_cstime */
short o_pgrp; /* p_pgrp */
int o_sigs; /* sum of SIGINT & SIGQUIT,
if == 2 proc is ignoring both.*/
* if == 2 proc is ignoring both.*/
char o_comm[MAXCOMLEN+1]; /* u_comm */
char o_args[64]; /* best guess at args to process */
};

View File

@@ -15,11 +15,6 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_PTMP "/etc/ptmp"
#define _PW_KEYBYNAME '0'
#define _PW_KEYBYUID '1'

7
include/regex.h Normal file
View File

@@ -0,0 +1,7 @@
#ifndef _REGEX_H
#define _REGEX_H
char *re_comp(const char *regex);
int re_exec(const char *string);
#endif

View File

@@ -5,6 +5,7 @@
* not the System V one.
*/
#define NSUBEXP 10
typedef struct regexp {
char *startp[NSUBEXP];
char *endp[NSUBEXP];

View File

@@ -1,42 +0,0 @@
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)stab.h 5.1 (Berkeley) 5/30/85
*/
/* IF YOU ADD DEFINITIONS, ADD THEM TO nm.c as well */
/*
* This file gives definitions supplementing <a.out.h>
* for permanent symbol table entries.
* These must have one of the N_STAB bits on,
* and are subject to relocation according to the masks in <a.out.h>.
*/
/*
* for symbolic debugger, sdb(1):
*/
#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
#define N_RSYM 0x40 /* register sym: name,,0,type,register */
#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,0,0,address */
#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
#define N_SOL 0x84 /* #included file name: name,,0,0,address */
#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,, */
#define N_ECOMM 0xe4 /* end common: name,, */
#define N_ECOML 0xe8 /* end common (local name): ,,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */

37
include/stdbool.h Normal file
View File

@@ -0,0 +1,37 @@
/*
* Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
* 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 THE AUTHOR 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 __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#ifndef __cplusplus
#define false 0
#define true 1
#define bool _Bool
#endif /* !__cplusplus */
#endif /* __bool_true_false_are_defined */

View File

@@ -1,8 +1,22 @@
#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_ */

View File

@@ -5,11 +5,26 @@
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 INT8_C(x) x
#define UINT8_C(x) x##U
#define INT16_C(x) x
#define UINT16_C(x) x##U
#define INT32_C(x) x
#define UINT32_C(x) x##U
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
#define INTMAX_C(x) x##LL
#define UINTMAX_C(x) x##ULL
#endif

View File

@@ -5,8 +5,6 @@
*/
#ifndef FILE
#include <sys/types.h>
#define BUFSIZ 1024
extern struct _iobuf {
int _cnt;
@@ -40,6 +38,11 @@ extern struct _iobuf {
#define NULL 0
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#define FILE struct _iobuf
#define EOF (-1)
@@ -62,17 +65,11 @@ extern struct _iobuf {
_flsbuf((unsigned char)(x), p)))
#endif /* not lint */
#define getchar() getc(stdin)
#define putchar(x) putc(x,stdout)
#define feof(p) (((p)->_flag&_IOEOF)!=0)
#define ferror(p) (((p)->_flag&_IOERR)!=0)
#define fileno(p) ((p)->_file)
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
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 *stream);
FILE *tmpfile (void);
int fclose (FILE *);
long ftell (FILE *);
@@ -80,6 +77,7 @@ int fflush (FILE *);
int fgetc (FILE *);
int ungetc (int, FILE *);
int fputc (int, FILE *);
int putchar (int);
int fputs (const char *, FILE *);
int puts (const char *);
char *fgets (char *, int, FILE *);
@@ -92,6 +90,7 @@ void setbuffer (FILE *, char *, size_t);
void setlinebuf (FILE *);
int setvbuf (FILE *, char *, int, size_t);
int fseek (FILE *, long, int);
int rename(const char *, const char *);
void rewind (FILE *);
int remove (const char *);
int getw(FILE *stream);
@@ -109,6 +108,13 @@ int fscanf (FILE *, const char *, ...);
int scanf (const char *, ...);
int sscanf (const char *, const char *, ...);
#define getchar() getc(stdin)
#define putchar(x) putc(x,stdout)
#define feof(p) (((p)->_flag&_IOEOF)!=0)
#define ferror(p) (((p)->_flag&_IOERR)!=0)
#define fileno(p) ((p)->_file)
#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
#ifndef _VA_LIST_
# ifdef __GNUC__
# define va_list __builtin_va_list /* For Gnu C */

View File

@@ -43,8 +43,6 @@
#ifndef _STDLIB_H_
#define _STDLIB_H_
#include <sys/types.h>
#ifndef NULL
#define NULL 0
#endif
@@ -54,51 +52,54 @@
#define RAND_MAX 0x7fff
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 (dev_t dev, mode_t 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);
#ifndef __SMALLER_C__
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 *);
#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 *);
#endif /* _STDLIB_H_ */

View File

@@ -3,12 +3,15 @@
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <sys/types.h>
#ifndef NULL
#define NULL 0
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
char *strcat (char *, const char *);
char *strncat (char *, const char *, size_t);
char *strcpy (char *, const char *);

View File

@@ -30,11 +30,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, unsigned long);
void bzero(void *, unsigned int);
int ffs(int);
char *index(const char *, int);
char *rindex(const char *, int);

View File

@@ -6,6 +6,6 @@ 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 (*)());
extern int tputs(register char *, int, int (*)(int));
#endif

View File

@@ -4,8 +4,6 @@
#include <sys/ioctl.h>
#include <stdint.h>
#define E_TERMCAP "/etc/termcap"
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
@@ -145,5 +143,4 @@ extern int tcsetattr(int, int, struct termios *);
#define TIOCSETAW _IOW(i, 92, struct termios)
#define TIOCSETAF _IOW(i, 92, struct termios)
#endif

View File

@@ -6,7 +6,19 @@
#ifndef _TIME_H
#define _TIME_H
#include <sys/types.h> /* for time_t */
#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)).
@@ -25,9 +37,11 @@ struct tm {
char *tm_zone;
};
extern struct tm *gmtime(), *localtime();
extern char *asctime(), *ctime();
extern time_t time();
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);

View File

@@ -5,14 +5,13 @@
/*
** 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 */
@@ -96,5 +95,4 @@ struct tzhead {
** Accurate only for the past couple of centuries;
** that will probably do.
*/
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)

View File

@@ -57,14 +57,16 @@
#define X_OK 1 /* Test for execute permission. */
#define F_OK 0 /* Test for existence. */
void _exit (int);
void _exit(int);
int access();
unsigned int alarm();
pid_t fork();
pid_t setsid(void);
gid_t getegid();
uid_t geteuid();
gid_t getgid();
char *getlogin();
int setlogin(const char *name);
pid_t getpgrp();
pid_t getpid();
pid_t getppid();
@@ -73,12 +75,12 @@ 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);
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);
void *brk(const void *addr);
int _brk(const void *addr);
char *crypt();
void endusershell();
long gethostid();
@@ -88,60 +90,74 @@ char *getwd();
void psignal();
extern char *sys_siglist[];
char *re_comp();
void *sbrk (int incr);
void *sbrk(int incr);
int sethostid();
void setusershell();
void sync();
void sync(void);
unsigned int ualarm();
void usleep();
int pause (void);
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);
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 isatty (int fd);
int chdir (const char *path);
int fchdir (int fd);
int chflags (const char *path, u_long flags);
int fchflags (int fd, u_long flags);
int getgroups (int size, gid_t list[]);
int getdtablesize (void);
int rmdir (const char *pathname);
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);
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, 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(void);
int isatty(int fd);
int chdir(const char *path);
int fchdir(int fd);
int chflags(const char *path, u_long flags);
int fchflags(int fd, u_long flags);
int getgroups(int size, gid_t list[]);
int getdtablesize(void);
int rmdir(const char *pathname);
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 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 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[]);
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);
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg; /* getopt(3) external variables */
extern int opterr, optind, optopt;
int gethostname(char *name, int namelen);
int sethostname(char *name, int namelen);
int chroot(const char *path);
int fsync(int fd);
int getpagesize(void);
int symlink(const char *target, const char *linkpath);
int vhangup(void);
int mknod(const char *, mode_t, dev_t);
int reboot(int howto);
int ttyslot(void);
#ifndef _VA_LIST_
# ifdef __GNUC__
# define va_list __builtin_va_list /* For Gnu C */
@@ -151,14 +167,14 @@ extern int opterr, optind, optopt;
# 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);
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

View File

@@ -25,3 +25,5 @@ struct utmp {
char ut_host[UT_HOSTSIZE];
long ut_time;
};
void login(struct utmp *ut);

View File

@@ -11,8 +11,7 @@
* Define segment+offset and modified macros.
* Place into the public domain.
* --------------------------------------------------
*/
*/
#include <sys/types.h>
#define MAXSEGNO 16384 /* max number of segments in a space */
@@ -24,12 +23,12 @@ 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 */
@@ -37,12 +36,11 @@ struct vseg { /* structure of a segment in memory */
struct vspace *s_vspace; /* which virtual space */
int s_lock_count;
int s_flags;
union
{
union {
int _winfo[WORDSPERSEG]; /* the actual segment */
char _cinfo[BYTESPERSEG];
} v_un;
};
};
#define s_winfo v_un._winfo
#define s_cinfo v_un._cinfo
@@ -50,15 +48,16 @@ struct vseg { /* structure of a segment in memory */
/* masks for s_flags */
#define S_DIRTY 01 /* segment has been modified */
long nswaps; /* number of swaps */
long nmapsegs; /* number of mapseg calls */
extern long nswaps; /* number of swaps */
extern long nmapsegs; /* number of mapseg calls */
int vminit(), vmopen();
struct vseg *vmmapseg();
void vmlock(), vmunlock(), vmclrseg(), vmmodify();
void vmflush(), vmclose();
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)

View File

@@ -1,21 +1,11 @@
TOPSRC = $(shell cd ..; pwd)
SUBDIR = startup libc libcurses libtermlib libwiznet
SUBDIR = startup libc libm libcurses libtermlib libwiznet libreadline libgpanel
PROG = ar as aout ld nm ranlib size strip
# Build a list of the host include directories.
CPP = $(shell gcc -print-prog-name=cc1)
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
# Add system include path
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
HOSTINC += -I/usr/include
else
HOSTINC += -I/usr/include/i386-linux-gnu
endif
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
-I$(TOPSRC)/src/cmd/as
CFLAGS = -Os -std=gnu89 -fno-builtin -g -Werror -Wall -DCROSS -I. \
-idirafter $(TOPSRC)/include \
-idirafter $(TOPSRC)/src/cmd/ar \
-idirafter $(TOPSRC)/src/cmd/as
LDFLAGS += -g
AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \

View File

@@ -8,7 +8,7 @@ vpath %.c $(LIBCDIR)/mips/sys $(LIBCDIR)/gen $(LIBCDIR)/stdio \
$(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \
$(LIBCDIR)/compat $(LIBCDIR)/runtime
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
ASFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -I$(LIBCDIR)/mips/sys
# modules which can not use SYSCALL and must be assembled from sources. The
@@ -87,15 +87,16 @@ 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 gtty.o memccpy.o memchr.o \
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 stty.o times.o tmpnam.o \
sigcompat.o strchr.o strrchr.o times.o tmpnam.o \
utime.o
# libc/runtime
OBJS += addsf3.o comparesf2.o divsf3.o fixsfsi.o floatsisf.o \
mulsf3.o negsf2.o subsf3.o sc_case.o
mulsf3.o negsf2.o subsf3.o sc_case.o fixunssfsi.o \
floatunsisf.o
all: ../libc.a

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libcurses
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
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 \

18
lib/libgpanel/Makefile Normal file
View File

@@ -0,0 +1,18 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libgpanel
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
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
../libgpanel.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a

18
lib/libm/Makefile Normal file
View File

@@ -0,0 +1,18 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libm
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
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: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a

17
lib/libreadline/Makefile Normal file
View File

@@ -0,0 +1,17 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libreadline
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = readline.o
all: ../libreadline.a
../libreadline.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libtermlib
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = termcap.o tgoto.o tputs.o tcattr.o

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libwiznet
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o

View File

@@ -9,7 +9,7 @@ TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/startup-mips
CFLAGS = -B$(TOPSRC)/lib/ -O -Wa,-x $(DEFS)
CFLAGS = -Os -B$(TOPSRC)/lib/ -fno-integrated-as -Xassembler -x $(DEFS)
OBJS = ../crt0.o

7
root/.profile Normal file
View File

@@ -0,0 +1,7 @@
echo 'erase ^?, kill ^U, intr ^C'
stty dec
PATH=/bin:/sbin:/etc
export PATH
HOME=/
export HOME
export TERM

File diff suppressed because it is too large Load Diff

8
share/.gitignore vendored
View File

@@ -1,4 +1,6 @@
re.help
misc
unixbench
calendar
emg.keys
misc
re.help
unixbench
zoneinfo

View File

@@ -1,20 +0,0 @@
all: ashello echo chello stdarg skeleton
ashello: ashello.o
$(LD) ashello.o -o $@
chello: chello.o
$(CC) chello.o -o $@
echo: echo.o
$(LD) $@.o -o $@
stdarg: stdarg.o
$(CC) stdarg.o -o $@
skeleton: skeleton.o
$(CC) skeleton.o -o $@
clean:
rm -f *.o ashello echo chello stdarg skeleton *.dis *~

View File

@@ -1,29 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: chello cplus echo stdarg
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > chello.dis
${SIZE} chello.elf
${ELF2AOUT} chello.elf $@
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
echo: echo.o
${LD} ${ASLDFLAGS} -o $@.elf $@.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
clean:
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~

View File

@@ -0,0 +1,11 @@
all: ashello echo
ashello: ashello.o
$(LD) ashello.o -o $@
echo: echo.o
$(LD) $@.o -o $@
clean:
rm -f *.o ashello echo *.dis *~

View File

@@ -0,0 +1,17 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.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 *~

50
share/examples/c/Makefile Normal file
View File

@@ -0,0 +1,50 @@
CC = cc
PROG = hello stdarg skeleton primelist primesum test1 test2 test3 \
gpio adc rain q8 tetris lcd6
all: $(PROG)
hello: hello.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
stdarg: stdarg.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
skeleton: skeleton.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primelist: primelist.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primesum: primesum.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
gpio: gpio.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
adc: adc.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
rain: rain.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
q8: q8.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
tetris: tetris.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
lcd6: lcd6.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test1: test1.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test2: test2.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test3: test3.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
clean:
rm -f *.o *~ $(PROG)

View File

@@ -0,0 +1,27 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror -Wall
all: chello stdarg lcd6
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > 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 *~

287
share/examples/c/lcd6.c Normal file
View File

@@ -0,0 +1,287 @@
/*
* 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 <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/gpio.h>
/*
* 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<sizeof(char_to_segm); i++) {
lcd_clear(char_to_segm[i]);
mdelay(200);
}
lcd_clear(0);
/* Display counter 0 to 999999. */
for (;;) {
for (i=0; i<999999; i++) {
lcd_display(i, i/10%4, i/10%4);
mdelay(100);
}
}
return 0;
}

666
share/examples/c/tetris.c Normal file
View File

@@ -0,0 +1,666 @@
/*
* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/gpio.h>
#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<NROW*NCOL/8; i++) {
gpanel_screen[i] = 0;
lcd_write(0, 1);
}
gpanel_row = 0;
gpanel_col = 0;
}
/*
* Lights a single pixel in the specified color
* at the specified x and y addresses
*/
void gpanel_pixel(int x, int y, int color)
{
unsigned char *data;
if (x >= 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; h<PITDEPTH; h++) {
for (w=0; w<PITWIDTH; w++) {
draw_block(h, w, 0);
pit[h][w] = 0;
}
pitcnt[h] = 0;
}
for (w=0; w<PITWIDTH; w++)
pit[PITDEPTH][w] = 1;
}
/*
* The piece reached the bottom
*/
void stopped(coord_t *c)
{
int h, nfull, w, k;
/* Count the full lines */
nfull = 0;
for (; c->x!=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; h<nfull; h++) {
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w]) {
draw_block(h, w, 0);
}
}
}
/* Move lines down */
k = nfull;
for (h=nfull; h<PITDEPTH && k>0; h++) {
if (pitcnt[h-k] == PITWIDTH) {
k--;
h--;
continue;
}
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w] != pit[h-k][w]) {
draw_block(h, w, pit[h-k][w]);
}
}
}
/* Now fix the pit contents */
for (h=PITDEPTH-1; h>0; 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: ;
}
}

View File

@@ -0,0 +1,15 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
all: cplus
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
clean:
rm -f *.o *.elf ${MAN} cplus *.elf *.dis tags *~

View File

@@ -0,0 +1,24 @@
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)

View File

@@ -0,0 +1,16 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.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 *~

View File

@@ -0,0 +1 @@
Examples for LED cube 8x8x8.

25
share/examples/cube/all.c Normal file
View File

@@ -0,0 +1,25 @@
/*
* Demo for LED cube 8x8x8.
* Turn on all LEDs.
*/
#include <stdio.h>
#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;
}

View File

@@ -0,0 +1,20 @@
/*
* Demo for LED cube 8x8x8.
* Test backlight LEDs.
*/
#include <stdio.h>
#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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,73 @@
/*
* Demo for LED cube 8x8x8.
* Switch between two static images.
*/
#include <stdio.h>
#include <sys/time.h>
#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;
}

View File

@@ -0,0 +1,13 @@
/*
* 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);

3118
share/examples/cube/demo.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,145 @@
/*
* 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 <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/gpio.h>
#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;
}
}
}

View File

@@ -0,0 +1,143 @@
/*
* 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 <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/gpio.h>
#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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -0,0 +1,20 @@
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)

Some files were not shown because too many files have changed in this diff Show More