Граф коммитов

1199 коммитов

Автор SHA1 Сообщение Дата
Ayke van Laethem
6bcb40fe01 os: implement virtual filesystem support
This allows applications to mount filesystems in the os package. This is
useful for mounting external flash filesystems, for example.
2020-05-13 08:08:57 +02:00
cornelk
e907db1481 os: add Args and stub it with mock data 2020-05-12 16:53:07 +02:00
Ayke van Laethem
6b8940421e avr: use standard pin numbering
This commit changes pin numbering for atmega328 based boards (Uno, Nano)
to use the standard format, where pin number is determined by the
pin/port. Previously, pin numbers were based on what the Uno uses, which
does not seem to have a clear pattern.

One difference is that counting starts at port B, as there is no port A.
So PB0 is 0, PB1 is 1… PC0 is 8.

This commit also moves PWM code to the atmega328 file, as it may not be
generic to all ATmega chips.
2020-05-12 08:16:34 +02:00
cornelk
2c71f08922 reflect: add Cap and Len support for map and chan 2020-05-12 01:17:27 +02:00
cornelk
7e64bc8f77 runtime: add cap and len support for chans 2020-05-12 01:17:27 +02:00
cornelk
acdaa72365 runtime: fix compilation errors when using gc.extalloc 2020-05-12 01:11:46 +02:00
Jaden Weiss
c54e1cc955 sync: modify sync.Cond 2020-05-09 01:08:56 +02:00
Jaden Weiss
afc6bd5cdd sync: add WaitGroup 2020-05-09 01:08:56 +02:00
Jaden Weiss
ae2cbbf851 internal/task: fix nil panic in (*internal/task.Stack).Pop
While adding some code to clear the Next field when popping from a task stack for safety reasons, the clear was placed outside of a nil pointer check.
As a result, (*internal/task.Stack).Pop panicked when the Stack is empty.
2020-05-09 01:08:56 +02:00
Jaden Weiss
ccd79ee289 add sync.Cond 2020-05-09 01:08:56 +02:00
Jaden Weiss
171d0fe123 implement mutex blocking 2020-05-09 01:08:56 +02:00
Ayke van Laethem
23e88bfb15 arm: allow nesting in DisableInterrupts and EnableInterrupts
This finally fixes a TODO left in the code.
2020-04-29 18:25:16 +02:00
Ayke van Laethem
6389e45d99 all: replace ReadRegister with AsmFull inline assembly
This makes AsmFull more powerful (by supporting return values) and
avoids a compiler builtin.
2020-04-29 18:25:16 +02:00
Ayke van Laethem
fc4857e98c runtime: avoid recursion in printuint64 function
This function is called from runtime.printitf, which is called from
runtime._panic, and is therefore the leaf function of many call paths.
This makes analyzing stack usage very difficult.

Also forwarding printuint32 to printuint64 as it reduces code size in
the few examples I've tested. Printing numbers is not often done so it
doesn't matter if it's a bit slow (the serial connection is probably
slower anyway).
2020-04-26 17:19:07 +02:00
Yannis Huber
f66492a338 Fix return address in scheduler 2020-04-26 16:58:02 +02:00
Jaden Weiss
ceeba528e7 runtime: copy stack scan assembly for GBA
The GC stack scanning code was implemented in the Cortex-M assembly, which meant that it was not available on the GBA which is pre-cortex.
This change adds a copy of the relevant code into a new asembly file which is used on the GBA.
2020-04-21 10:28:42 +02:00
Ayke van Laethem
f00bb63330 runtime: do not put scheduler and GC code in the same section
This allows dead code elimination and avoids linker errors with
-scheduler=leaking.
2020-04-20 21:32:29 +02:00
Jaden Weiss
9c78f7039d runtime (chan): fix blocking select on a nil channel
Previously, a blocking select on a nil channel would result in a nil panic inside the channel runtime code.
This change fixes the nil checks so that the select works as intended.
2020-04-13 08:28:24 +02:00
Jaden Weiss
e077e35386 runtime (gc): split marking into two phases 2020-04-09 14:13:10 +02:00
Jaden Weiss
4a6fba7e3a runtime (gc): remove recursion from "conservative" GC 2020-04-09 14:13:10 +02:00
Ayke van Laethem
012c4a02c9 machine: switch to modern interrupt registration method
This saves about 112 bytes in flash and 288 bytes in RAM when the UART
is not used.
2020-04-07 17:53:52 +02:00
Ayke van Laethem
8333c171f4 hifive1-qemu: fix compile error and add smoke test
This probably got broken with this PR:
https://github.com/tinygo-org/tinygo/pull/976
2020-04-07 16:17:10 +02:00
Ayke van Laethem
b8f5627c9f machine: move errors.New calls to globals
Calling errors.New in an error path causes a heap allocation at an
already unfortunate moment. It is more efficient to create these error
values in globals and return these constant globals. If these errors are
not used (because the related code was optimized out), the globals will
also be optimized out.
2020-04-07 13:24:26 +02:00
Jaden Weiss
9f8715c143 runtime (gc): scan callee-saved registers while marking stack 2020-04-07 11:50:50 +02:00
Ayke van Laethem
cbaa58a2d9 all: change //go:export to //export
This is the kind that is used in Go (actually CGo) for exporting
functions. I think it's best to use //export instead of our custom
//go:export pragma, for consistency (they are equivalent in TinyGo).
Therefore I've updated all instances to the standard format (except for
two that are updated in https://github.com/tinygo-org/tinygo/pull/1024).

No smoke tests changed (when comparing the output hash), except for some
wasm tests that include DWARF debug info and tend to be flaky anyway.
2020-04-05 16:16:57 +02:00
Ron Evans
5d539df216 machine/atsamd21,atsamd51: clear the USB packet size before setting it again when sending
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-04-02 11:09:24 -04:00
Yannis Huber
6e86daa95e
riscv: add I2C support for the SiFive HiFive1 Rev B board 2020-04-01 13:04:25 +02:00
Jaden Weiss
62e78c0a26 runtime (gc): add garbage collector that uses an external allocator 2020-03-30 14:35:29 +02:00
BCG
57320c0922
runtime: export implementations of malloc/free for use from C 2020-03-30 14:22:42 +02:00
Ron Evans
03fa9dd9b7 machine/atsamd21,atsamd51,nrf52840: refactor USB CDC device descriptor to reduce code duplication and heap allocations
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-29 17:54:58 +02:00
Ron Evans
06797b6d1a machine/atsamd21,atsamd51,nrf52840: correct USB CDC composite descriptors
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-29 17:54:58 +02:00
Jaden Weiss
5cc130bb6e
compiler: implement spec-compliant shifts
Previously, the compiler used LLVM's shift instructions directly, which have UB whenever the shifts are large or negative.
This commit adds runtime checks for negative shifts, and handles oversized shifts.
2020-03-28 17:35:19 +01:00
Ayke van Laethem
91d1a23b14 compiler,runtime: translate memzero calls to LLVM memset intrinsics
This gives the optimizer a bit more information about what the calls do.
This should result in slightly better generated code.

Code size sometimes goes up and sometimes goes down. I blame the code
size going up on the inliner which inlines more functions, because
compiling the smoke tests in the drivers repository with -opt=1 results
in a slight code size reduction in all cases.
2020-03-27 21:01:59 +01:00
Ayke van Laethem
eaa54bc7e3 compiler,runtime: use LLVM intrinsics for memcpy/memmove
This replaces the custom runtime.memcpy and runtime.memmove functions
with calls to LLVM builtins that should hopefully allow LLVM to better
optimize such calls. They will be lowered to regular libc memcpy/memmove
when they can't be optimized away.

When testing this change with some smoke tests, I found that many smoke
tests resulted in slightly larger binary sizes with this commit applied.
I looked into it and it appears that machine.sendUSBPacket was not
inlined before while it is with this commit applied. Additionally, when
I compared all driver smoke tests with -opt=1 I saw that many were
reduced slightly in binary size and none increased in size.
2020-03-27 21:01:59 +01:00
Ayke van Laethem
c01f81144e machine: avoid binary size regression after LLVM memory intrinsics
Somehow moving to LLVM memory intrinsics for calls like memcpy made the
machine.sendUSBPacket get inlined. This is a problem because it is
called in many different functions and it is just big enough to cause a
significant file size increase.

Adding //go:noinline solves this problem and gets the examples/blinky1
program below the file size it was before this change (tested:
itsybitsy-m0, itsybitsy-m4, circuitplay-bluefruit).
2020-03-27 21:00:54 +01:00
Ayke van Laethem
67c242173c sync: implement sync.Map
This is a very simple implementation, just enough to get packages to
compile.
2020-03-27 19:02:45 +01:00
Ayke van Laethem
f8876ea245 compiler, transform: remove runtime.isnil hack
This hack was originally introduced in
https://github.com/tinygo-org/tinygo/pull/251 to fix an escape analysis
regression after https://github.com/tinygo-org/tinygo/pull/222
introduced nil checks. Since a new optimization in LLVM (see
https://reviews.llvm.org/D60047) this hack is not necessary anymore and
can be removed.

I've compared all regular tests and smoke tests before and after to
check the size. In most cases this change was an improvement although
there are a few regressions.
2020-03-27 07:38:16 +01:00
Ayke van Laethem
980068543a riscv: implement VirtIO target
This allows running RISC-V tests in CI using QEMU, which should help
catch bugs.
2020-03-26 23:03:55 +01:00
Ayke van Laethem
8c86eae924 avr: clean up ATtiny definitions
Add definitions for constants like PB0.
2020-03-25 19:47:36 +01:00
GeoffThomas
b4dddfe439 stm32 add SPI for stm32f4 2020-03-25 16:24:19 +01:00
Travis McLane
83426edcdc
avr: add Arduino Mega 2560 2020-03-24 22:24:47 +01:00
Wojtek Siudzinski
5133604b51
machine: set USB CDC identifiers to Particle ones 2020-03-24 14:42:10 +01:00
Ayke van Laethem
f316ebc23b all: include picolibc for bare metal targets
This is necessary for better CGo support on bare metal. Existing
libraries expect to be able to include parts of libc and expect to be
able to link to those symbols.

Because with this all targets have a working libc, it is now possible to
add tests to check that a libc in fact works basically.

Not all parts of picolibc are included, such as the math or stdio parts.
These should be added later, when needed.

This commit also avoids the need for the custom memcpy/memset/memcmp
symbols that are sometimes emitted by LLVM. The C library will take care
of that.
2020-03-22 17:14:59 +01:00
GeoffThomas
c61c5e5799 refactor stm32 UART code 2020-03-22 07:02:17 +01:00
Ron Evans
046efdd93a machine/stm32f103xx: enable clock on configure of GPIO pin
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-21 20:47:46 +01:00
Ayke van Laethem
add014f21b avr: add support for tasks scheduler
This adds support for the `-scheduler=tasks` flag for AVR. On most AVR
chips you wouldn't want to run a real scheduler but it may be useful in
some cases, especially on devices with more RAM. It is disabled by
default.
2020-03-20 15:12:05 +01:00
Ron Evans
fa861085c0 machine/adafruit: make all USB vendor and product names string descriptors consistent
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-18 12:08:15 +01:00
Ron Evans
a02d4e0b77 machine/nrf52840: use correct USB device descriptor and string descriptor for nrf52840 based boards
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-18 12:08:15 +01:00
Ron Evans
9f597bbbc3 machine/nrf52840: add correct USB VID and PID for all nrf52840 based boards
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-18 12:08:15 +01:00
Ron Evans
c03e3616a2 machine/atsamd21 and atsamd51: corrections needed to return valid UCB CDC device and string descriptors
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-03-18 12:08:15 +01:00