2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 #include "ao-bringup.h"
20 #define AO_STACK_SIZE 128
22 #define PUSH8(stack, val) (*((stack)--) = (val))
28 LEDPORT ^= (1 << LEDOUT);
35 init_stack(uint8_t *stack_base, int size, void (*f) (void))
37 uint8_t *stack = stack_base + size - 1;
48 /* Clear register values */
53 /* SREG with interrupts enabled */
59 switch_stack(uint8_t *sp) __attribute__((naked));
62 switch_stack(uint8_t *sp)
67 sp_h = ((uint16_t) sp) >> 8;
68 asm volatile ("out __SP_H__,%0" : : "r" (sp_h) );
69 asm volatile ("out __SP_L__,%0" : : "r" (sp_l) );
70 asm volatile("pop r0" "\n\t"
72 asm volatile("pop r0" "\n\t"
77 asm volatile("pop r5" "\n\t"
82 asm volatile("pop r10" "\n\t"
87 asm volatile("pop r15" "\n\t"
92 asm volatile("pop r20" "\n\t"
97 asm volatile("pop r25" "\n\t"
102 asm volatile("pop r30" "\n\t"
107 uint8_t new_stack[512];
114 printf("starting\n");
116 stack = init_stack(new_stack, sizeof (new_stack), blink);