Keith Packard [Sat, 19 Nov 2016 06:41:46 +0000 (22:41 -0800)]
altos/lisp: Sort frames by atom
Fortunately, the collector always retains the relative order between
addresses, so we can sort based on the atom address itself. This
reduces the time spent looking for names in larger (e.g. global)
frames.
Keith Packard [Wed, 16 Nov 2016 22:12:59 +0000 (14:12 -0800)]
altos/lisp: Eliminate compiler warning about array bounds at -O3
Using ao_lisp_pool - 4 caused the compiler to whinge about computing
an address outside the bounds of the array. Sigh. Restructure the code
to do the adjustment-by-4 in the integer computations instead of the
pointer ones.
Keith Packard [Wed, 16 Nov 2016 20:34:14 +0000 (12:34 -0800)]
altos/lisp: Add incremental collection
Realizing that long-lived objects will eventually float to the bottom
of the heap, I added a simple hack to the collector that 'remembers'
the top of the heap the last time a full collect was run and then runs
incremental collects looking to shift only objects above that
boundary. That doesn't perfectly capture the bounds of transient
objects, but does manage to reduce the amount of time spent not moving
persistent objects each time through the collector.
Keith Packard [Wed, 16 Nov 2016 04:21:47 +0000 (20:21 -0800)]
altos/lisp: Allow macro/nlambda/lexpr to have multiple args
Entries from the params are bound to the formals with whatever
remaining formals there are bound to the last argument as a list.
This makes writing functions a bit easier.
Keith Packard [Wed, 16 Nov 2016 04:18:59 +0000 (20:18 -0800)]
altos/lisp: re-use small frames
This saves a pile more use of the allocator by noting when frames have
not been referenced from another frame and freeing them when they go
out of scope. Frames with references are left to the allocator to deal
with.
Keith Packard [Tue, 15 Nov 2016 03:55:36 +0000 (19:55 -0800)]
altos/lisp: Simplify GC a bit by only marking the head of each object
We don't need to mark the whole object now as we're getting
information about where objects are by walking the tree each time
around the loop; ao_lisp_busy is only useful for terminating the walk
now.
Keith Packard [Sat, 12 Nov 2016 05:16:09 +0000 (21:16 -0800)]
altos/lisp: Add save/restore infrastructure. Needs OS support to work.
This sticks a few globals past the end of the heap and then asks the
OS to save the heap. On restore, the heap is re-populated by the OS
and then various global variables reset.
Keith Packard [Sat, 12 Nov 2016 05:11:13 +0000 (21:11 -0800)]
altos/lisp: Make sure memmove only happens once per object. Other GC fixes
The memmove may be overlapping, so make sure it happens only once by
just checking whether move_size has been set, rather than looking at
ao_lisp_moving; that doesn't get set when moving a noted cons as that
still needs to be walked at a later time.
Fix up the various looping move functions to all use the same
pattern. Atom was busted.
Keith Packard [Fri, 11 Nov 2016 07:29:21 +0000 (23:29 -0800)]
altos/lisp: Deal with memory compation in the middle of operations
Handle memory compaction in places where we've got pointers into the
heap across an allocation operation. Either re-compute the values from
managed global references or add new roots across the allocation.
Keith Packard [Wed, 9 Nov 2016 19:13:58 +0000 (11:13 -0800)]
altos/lisp: macros appear to work now
Needed an extra stack frame to stash the pre-macro state. This
simplified macro processing quite a bit; a macro now just evaluates
the function and then sends that result to be evaluated again.
Keith Packard [Sat, 5 Nov 2016 21:51:58 +0000 (14:51 -0700)]
altos/lisp: Change GC move API
Pass reference to move API so it can change the values in-place, then
let it return '1' when the underlying object has already been moved to
shorten GC times.
Keith Packard [Thu, 3 Nov 2016 05:56:01 +0000 (22:56 -0700)]
altos/lisp: Separate out values from atoms
This enables changing values of atoms declared as constants, should
enable lets, and with some work, even lexical scoping.
this required changing the constant computation to run
ao_lisp_collect() before dumping the block of constant data, and that
uncovered some minor memory manager bugs.
Keith Packard [Wed, 2 Nov 2016 04:14:45 +0000 (21:14 -0700)]
altos/lisp: Change lisp objects to use ao_poly everywhere. Add const
This makes all lisp objects use 16-bit ints for references so we can
hold more stuff in small amounts of memory. Also adds a separate
constant pool of lisp objects for builtins, initial atoms and constant
lisp code.
Keith Packard [Sun, 18 Dec 2016 04:58:36 +0000 (20:58 -0800)]
altos/arm: Align data so that gcc 5.4 doesn't do byte-accesses. Add -Wcast-align
Gcc 5.4.1 tracks alignment of data through assignments, so that a
uint32_t pointer which comes from byte-aligned uint8_t data:
extern uint8_t foo[];
uint32_t *q = (void *) foo;
Fetches and stores through this pointer are done bytewise. This is
slow (meh), but if q references a device register, things to bad very
quickly.
This patch works around this bug in the compiler by adding
__attribute__((aligned(4))) tags to some variables, or changing them
from uint8_t to uint32_t. Places doing this will now be caught as I've
added -Wcast-align to the compiler flags. That required adding (void
*) casts, after the relevant code was checked to make sure the
compiler could tell that the addresses were aligned.
Keith Packard [Sat, 3 Sep 2016 06:21:34 +0000 (01:21 -0500)]
altos/stm: Set SPI slave DMA priority to HIGH/VERY_HIGH
Set spi slave DMA priority MOSI to HIGH and MISO to VERY_HIGH. Slave
SPI doesn't have the luxury of slowing down when the system is busy,
so provide it maximum memory bandwidth to try and keep up with the
master.
Keith Packard [Sat, 3 Sep 2016 05:55:19 +0000 (00:55 -0500)]
altos/stm: Set MISO DMA priority to HIGH to avoid OVR
When the MISO DMA priority is too low, and the processor gets busy,
it's possible for SPI input to overrun the processor, which causes the
MISO DMA to get out of sync and never finish. Set the MISO DMA
priority to HIGH to avoid this.
Keith Packard [Sat, 3 Sep 2016 05:53:44 +0000 (00:53 -0500)]
altos/stm: Create funcs to set SPI DMA parameters
Instead of having nearly duplicate versions of the SPI DMA
configuration calls, create helper funcs that do most of the work so
that the SPI API funcs are shorter and clearer.
Keith Packard [Sat, 3 Sep 2016 04:36:36 +0000 (23:36 -0500)]
ao-tools/ao-cal-freq: Re-open usb device each try
Instead of trying to re-use the same file descriptor, close and
re-open the device each time around the loop to avoid getting stuck
when calibrating TeleMega boards.
The code to validate the usb id and product name had some debug hacks
left enabled, which caused it to fail. The short -f version of the
force flag was also not getting parsed correctly.