[ar71xx] update kernel config
[openwrt.git] / toolchain / uClibc / patches / 007-avr32.patch
1 --- a/Rules.mak
2 +++ b/Rules.mak
3 @@ -313,6 +313,12 @@ ifeq ($(TARGET_ARCH),frv)
4 UCLIBC_LDSO=ld.so.1
5 endif
6
7 +ifeq ($(strip $(TARGET_ARCH)),avr32)
8 + CPU_CFLAGS-$(CONFIG_AVR32_AP7) += -march=ap
9 + CPU_CFLAGS-$(CONFIG_LINKRELAX) += -mrelax
10 + CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
11 +endif
12 +
13 # Keep the check_gcc from being needlessly executed
14 ifndef PIEFLAG
15 ifneq ($(UCLIBC_BUILD_PIE),y)
16 --- /dev/null
17 +++ b/extra/Configs/Config.avr32
18 @@ -0,0 +1,31 @@
19 +#
20 +# For a description of the syntax of this configuration file,
21 +# see extra/config/Kconfig-language.txt
22 +#
23 +
24 +config TARGET_ARCH
25 + string
26 + default "avr32"
27 +
28 +config FORCE_OPTIONS_FOR_ARCH
29 + bool
30 + default y
31 + select ARCH_BIG_ENDIAN
32 + select FORCE_SHAREABLE_TEXT_SEGMENTS
33 +
34 +config ARCH_CFLAGS
35 + string
36 +
37 +choice
38 + prompt "Target CPU Type"
39 + default CONFIG_AVR32_AP7
40 +
41 +config CONFIG_AVR32_AP7
42 + bool "AVR32 AP7"
43 + select ARCH_HAS_MMU
44 +
45 +endchoice
46 +
47 +config LINKRELAX
48 + bool "Enable linker optimizations"
49 + default y
50 --- a/extra/Configs/Config.in
51 +++ b/extra/Configs/Config.in
52 @@ -16,6 +16,9 @@ config TARGET_alpha
53 config TARGET_arm
54 bool "arm"
55
56 +config TARGET_avr32
57 + bool "avr32"
58 +
59 config TARGET_bfin
60 bool "bfin"
61
62 @@ -92,6 +95,10 @@ if TARGET_arm
63 source "extra/Configs/Config.arm"
64 endif
65
66 +if TARGET_avr32
67 +source "extra/Configs/Config.avr32"
68 +endif
69 +
70 if TARGET_bfin
71 source "extra/Configs/Config.bfin"
72 endif
73 --- /dev/null
74 +++ b/extra/Configs/defconfigs/avr32
75 @@ -0,0 +1 @@
76 +TARGET_avr32=y
77 --- a/include/elf.h
78 +++ b/include/elf.h
79 @@ -354,6 +354,8 @@ typedef struct
80 /* NIOS magic number - no EABI available. */
81 #define EM_NIOS32 0xFEBB
82
83 +#define EM_AVR32 0x18ad
84 +
85 /* V850 backend magic number. Written in the absense of an ABI. */
86 #define EM_CYGNUS_V850 0x9080
87
88 @@ -2828,6 +2830,55 @@ typedef Elf32_Addr Elf32_Conflict;
89 /* Keep this the last entry. */
90 #define R_V850_NUM 25
91
92 +/* Atmel AVR32 relocations. */
93 +#define R_AVR32_NONE 0
94 +#define R_AVR32_32 1
95 +#define R_AVR32_16 2
96 +#define R_AVR32_8 3
97 +#define R_AVR32_32_PCREL 4
98 +#define R_AVR32_16_PCREL 5
99 +#define R_AVR32_8_PCREL 6
100 +#define R_AVR32_DIFF32 7
101 +#define R_AVR32_DIFF16 8
102 +#define R_AVR32_DIFF8 9
103 +#define R_AVR32_GOT32 10
104 +#define R_AVR32_GOT16 11
105 +#define R_AVR32_GOT8 12
106 +#define R_AVR32_21S 13
107 +#define R_AVR32_16U 14
108 +#define R_AVR32_16S 15
109 +#define R_AVR32_8S 16
110 +#define R_AVR32_8S_EXT 17
111 +#define R_AVR32_22H_PCREL 18
112 +#define R_AVR32_18W_PCREL 19
113 +#define R_AVR32_16B_PCREL 20
114 +#define R_AVR32_16N_PCREL 21
115 +#define R_AVR32_14UW_PCREL 22
116 +#define R_AVR32_11H_PCREL 23
117 +#define R_AVR32_10UW_PCREL 24
118 +#define R_AVR32_9H_PCREL 25
119 +#define R_AVR32_9UW_PCREL 26
120 +#define R_AVR32_HI16 27
121 +#define R_AVR32_LO16 28
122 +#define R_AVR32_GOTPC 29
123 +#define R_AVR32_GOTCALL 30
124 +#define R_AVR32_LDA_GOT 31
125 +#define R_AVR32_GOT21S 32
126 +#define R_AVR32_GOT18SW 33
127 +#define R_AVR32_GOT16S 34
128 +#define R_AVR32_GOT7UW 35
129 +#define R_AVR32_32_CPENT 36
130 +#define R_AVR32_CPCALL 37
131 +#define R_AVR32_16_CP 38
132 +#define R_AVR32_9W_CP 39
133 +#define R_AVR32_RELATIVE 40
134 +#define R_AVR32_GLOB_DAT 41
135 +#define R_AVR32_JMP_SLOT 42
136 +#define R_AVR32_ALIGN 43
137 +#define R_AVR32_NUM 44
138 +
139 +/* AVR32 dynamic tags */
140 +#define DT_AVR32_GOTSZ 0x70000001 /* Total size of GOT in bytes */
141
142 /* Renesas H8/300 Relocations */
143 #define R_H8_NONE 0
144 --- a/ldso/include/dl-string.h
145 +++ b/ldso/include/dl-string.h
146 @@ -285,7 +285,8 @@ static __always_inline char * _dl_simple
147 /* On some arches constant strings are referenced through the GOT.
148 * This requires that load_addr must already be defined... */
149 #if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
150 - defined(__mips__) || defined(__sh__) || defined(__powerpc__)
151 + defined(__mips__) || defined(__sh__) || defined(__powerpc__) || \
152 + defined(__avr32__)
153 # define CONSTANT_STRING_GOT_FIXUP(X) \
154 if ((X) < (const char *) load_addr) (X) += load_addr
155 # define NO_EARLY_SEND_STDERR
156 --- a/ldso/include/dl-syscall.h
157 +++ b/ldso/include/dl-syscall.h
158 @@ -55,69 +55,69 @@
159 dynamic linking at all, so we cannot return any error codes.
160 We just punt if there is an error. */
161 #define __NR__dl_exit __NR_exit
162 -static inline _syscall1(void, _dl_exit, int, status);
163 +static __always_inline _syscall1(void, _dl_exit, int, status);
164
165 #define __NR__dl_close __NR_close
166 -static inline _syscall1(int, _dl_close, int, fd);
167 +static __always_inline _syscall1(int, _dl_close, int, fd);
168
169 #define __NR__dl_open __NR_open
170 -static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
171 +static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
172 __kernel_mode_t, mode);
173
174 #define __NR__dl_write __NR_write
175 -static inline _syscall3(unsigned long, _dl_write, int, fd,
176 +static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
177 const void *, buf, unsigned long, count);
178
179 #define __NR__dl_read __NR_read
180 -static inline _syscall3(unsigned long, _dl_read, int, fd,
181 +static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
182 const void *, buf, unsigned long, count);
183
184 #define __NR__dl_mprotect __NR_mprotect
185 -static inline _syscall3(int, _dl_mprotect, const void *, addr,
186 +static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
187 unsigned long, len, int, prot);
188
189 #define __NR__dl_stat __NR_stat
190 -static inline _syscall2(int, _dl_stat, const char *, file_name,
191 +static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
192 struct stat *, buf);
193
194 #define __NR__dl_fstat __NR_fstat
195 -static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
196 +static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
197
198 #define __NR__dl_munmap __NR_munmap
199 -static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
200 +static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
201
202 #ifdef __NR_getxuid
203 # define __NR_getuid __NR_getxuid
204 #endif
205 #define __NR__dl_getuid __NR_getuid
206 -static inline _syscall0(uid_t, _dl_getuid);
207 +static __always_inline _syscall0(uid_t, _dl_getuid);
208
209 #ifndef __NR_geteuid
210 # define __NR_geteuid __NR_getuid
211 #endif
212 #define __NR__dl_geteuid __NR_geteuid
213 -static inline _syscall0(uid_t, _dl_geteuid);
214 +static __always_inline _syscall0(uid_t, _dl_geteuid);
215
216 #ifdef __NR_getxgid
217 # define __NR_getgid __NR_getxgid
218 #endif
219 #define __NR__dl_getgid __NR_getgid
220 -static inline _syscall0(gid_t, _dl_getgid);
221 +static __always_inline _syscall0(gid_t, _dl_getgid);
222
223 #ifndef __NR_getegid
224 # define __NR_getegid __NR_getgid
225 #endif
226 #define __NR__dl_getegid __NR_getegid
227 -static inline _syscall0(gid_t, _dl_getegid);
228 +static __always_inline _syscall0(gid_t, _dl_getegid);
229
230 #ifdef __NR_getxpid
231 # define __NR_getpid __NR_getxpid
232 #endif
233 #define __NR__dl_getpid __NR_getpid
234 -static inline _syscall0(gid_t, _dl_getpid);
235 +static __always_inline _syscall0(gid_t, _dl_getpid);
236
237 #define __NR__dl_readlink __NR_readlink
238 -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
239 +static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
240 size_t, bufsiz);
241
242 #ifdef __UCLIBC_HAS_SSP__
243 @@ -146,14 +146,14 @@ static inline _syscall2(int, _dl_gettime
244 #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
245
246 # define __NR__dl_mmap __NR_mmap
247 -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
248 +static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
249 int, prot, int, flags, int, fd, off_t, offset);
250
251 /* then try mmap2() */
252 #elif defined(__NR_mmap2)
253
254 # define __NR___syscall_mmap2 __NR_mmap2
255 -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
256 +static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
257 int, prot, int, flags, int, fd, off_t, offset);
258
259 /* Some architectures always use 12 as page shift for mmap2() eventhough the
260 @@ -164,7 +164,7 @@ static inline _syscall6(__ptr_t, __sysca
261 # define MMAP2_PAGE_SHIFT 12
262 #endif
263
264 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
265 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
266 int flags, int fd, unsigned long offset)
267 {
268 if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
269 @@ -177,8 +177,8 @@ static inline void * _dl_mmap(void * add
270 #elif defined(__NR_mmap)
271
272 # define __NR__dl_mmap_real __NR_mmap
273 -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
274 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
275 +static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
276 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
277 int flags, int fd, unsigned long offset)
278 {
279 unsigned long buffer[6];
280 --- /dev/null
281 +++ b/ldso/ldso/avr32/dl-debug.h
282 @@ -0,0 +1,45 @@
283 +/*
284 + * AVR32 ELF shared libary loader support
285 + *
286 + * Copyright (C) 2005-2007 Atmel Corporation
287 + * All rights reserved.
288 + *
289 + * Redistribution and use in source and binary forms, with or without
290 + * modification, are permitted provided that the following conditions
291 + * are met:
292 + * 1. Redistributions of source code must retain the above copyright
293 + * notice, this list of conditions and the following disclaimer.
294 + * 2. The name of the above contributors may not be
295 + * used to endorse or promote products derived from this software
296 + * without specific prior written permission.
297 + *
298 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
299 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
300 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
301 + * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
302 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
303 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
304 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
305 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
306 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
307 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
308 + * SUCH DAMAGE.
309 + */
310 +
311 +static const char *_dl_reltypes_tab[] = {
312 + "R_AVR32_NONE",
313 + "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
314 + "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
315 + "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
316 + "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
317 + "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
318 + "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
319 + "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
320 + "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
321 + "R_AVR32_HI16", "R_AVR32_LO16",
322 + "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
323 + "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
324 + "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
325 + "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
326 + "R_AVR32_ALIGN",
327 +};
328 --- /dev/null
329 +++ b/ldso/ldso/avr32/dl-startup.h
330 @@ -0,0 +1,112 @@
331 +/*
332 + * Architecture specific code used by dl-startup.c
333 + *
334 + * Copyright (C) 2005-2007 Atmel Corporation
335 + *
336 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
337 + */
338 +
339 +/* This is the library loader's main entry point. Let _dl_boot2 do its
340 + * initializations and jump to the application's entry point
341 + * afterwards. */
342 +asm( " .text\n"
343 + " .global _start\n"
344 + " .type _start,@function\n"
345 + "_start:\n"
346 + /* All arguments are on the stack initially */
347 + " mov r12, sp\n"
348 + " rcall _dl_start\n"
349 + /* Returns user entry point in r12. Save it. */
350 + " mov r0, r12\n"
351 + /* We're PIC, so get the Global Offset Table */
352 + " lddpc r6, .L_GOT\n"
353 + ".L_RGOT:\n"
354 + " rsub r6, pc\n"
355 + /* Adjust argc and argv according to _dl_skip_args */
356 + " ld.w r1, r6[_dl_skip_args@got]\n"
357 + " ld.w r1, r1[0]\n"
358 + " ld.w r2, sp++\n"
359 + " sub r2, r1\n"
360 + " add sp, sp, r1 << 2\n"
361 + " st.w --sp, r2\n"
362 + /* Load the finalizer function */
363 + " ld.w r12, r6[_dl_fini@got]\n"
364 + /* Jump to the user's entry point */
365 + " mov pc, r0\n\n"
366 +
367 + " .align 2\n"
368 + ".L_GOT:"
369 + " .long .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
370 + " .size _start, . - _start\n"
371 + " .previous\n");
372 +
373 +/* Get a pointer to the argv array. On many platforms this can be just
374 + * the address if the first argument, on other platforms we need to
375 + * do something a little more subtle here. */
376 +#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
377 +
378 +
379 +/* We can't call functions before the GOT has been initialized */
380 +#define NO_FUNCS_BEFORE_BOOTSTRAP
381 +
382 +/*
383 + * Relocate the GOT during dynamic loader bootstrap. This will add
384 + * the load address to all entries in the GOT, which is necessary
385 + * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
386 + * GOT.
387 + */
388 +static __always_inline
389 +void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
390 +{
391 + Elf32_Addr i, nr_got;
392 + register Elf32_Addr *__r6 __asm__("r6");
393 + Elf32_Addr *got = __r6;
394 +
395 + nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
396 + for (i = 2; i < nr_got; i++)
397 + got[i] += tpnt->loadaddr;
398 +}
399 +
400 +#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
401 +
402 +/* Handle relocation of the symbols in the dynamic loader. */
403 +static __always_inline
404 +void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
405 + unsigned long symbol_addr,
406 + unsigned long load_addr, Elf32_Sym *symtab)
407 +{
408 + switch(ELF32_R_TYPE(rpnt->r_info)) {
409 + case R_AVR32_NONE:
410 + break;
411 + case R_AVR32_GLOB_DAT:
412 + case R_AVR32_JMP_SLOT:
413 + *reloc_addr = symbol_addr;
414 + break;
415 + case R_AVR32_RELATIVE:
416 + SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
417 + SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
418 + SEND_STDERR_DEBUG(" + ");
419 + SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
420 + *reloc_addr = load_addr + rpnt->r_addend;
421 + break;
422 + default:
423 + SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
424 + SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
425 + SEND_STDERR("REL, SYMBOL, LOAD: ");
426 + SEND_ADDRESS_STDERR(reloc_addr, 0);
427 + SEND_STDERR(", ");
428 + SEND_ADDRESS_STDERR(symbol_addr, 0);
429 + SEND_STDERR(", ");
430 + SEND_ADDRESS_STDERR(load_addr, 1);
431 + _dl_exit(1);
432 + }
433 +}
434 +
435 +/* Transfer control to the user's application, once the dynamic loader
436 + * is done. This routine has to exit the current function, then call
437 + * the _dl_elf_main function.
438 + *
439 + * Since our _dl_boot will simply call whatever is returned by
440 + * _dl_boot2, we can just return the address we're supposed to
441 + * call. */
442 +#define START() return _dl_elf_main;
443 --- /dev/null
444 +++ b/ldso/ldso/avr32/dl-syscalls.h
445 @@ -0,0 +1,6 @@
446 +/* We can't use the real errno in ldso, since it has not yet
447 + * been dynamicly linked in yet. */
448 +#include "sys/syscall.h"
449 +extern int _dl_errno;
450 +#undef __set_errno
451 +#define __set_errno(X) {(_dl_errno) = (X);}
452 --- /dev/null
453 +++ b/ldso/ldso/avr32/dl-sysdep.h
454 @@ -0,0 +1,105 @@
455 +/*
456 + * Various assembly language/system dependent hacks that are required
457 + * so that we can minimize the amount of platform specific code.
458 + *
459 + * Copyright (C) 2004-2007 Atmel Corporation
460 + *
461 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
462 + */
463 +
464 +/* Define this if the system uses RELOCA. */
465 +#define ELF_USES_RELOCA
466 +
467 +#include <elf.h>
468 +
469 +#define ARCH_NUM 1
470 +#define DT_AVR32_GOTSZ_IDX (DT_NUM + OS_NUM)
471 +
472 +#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
473 + do { \
474 + if (dpnt->d_tag == DT_AVR32_GOTSZ) \
475 + dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
476 + } while (0)
477 +
478 +/* Initialization sequence for the application/library GOT. */
479 +#define INIT_GOT(GOT_BASE,MODULE) \
480 + do { \
481 + unsigned long i, nr_got; \
482 + \
483 + GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
484 + GOT_BASE[1] = (unsigned long) MODULE; \
485 + \
486 + /* Add load address displacement to all GOT entries */ \
487 + nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
488 + for (i = 2; i < nr_got; i++) \
489 + GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
490 + } while (0)
491 +
492 +#define do_rem(result, n, base) ((result) = (n) % (base))
493 +
494 +/* Here we define the magic numbers that this dynamic loader should accept */
495 +#define MAGIC1 EM_AVR32
496 +#undef MAGIC2
497 +
498 +/* Used for error messages */
499 +#define ELF_TARGET "AVR32"
500 +
501 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
502 +
503 +/* 4096 bytes alignment */
504 +#define PAGE_ALIGN 0xfffff000
505 +#define ADDR_ALIGN 0xfff
506 +#define OFFS_ALIGN 0x7ffff000
507 +
508 +#define elf_machine_type_class(type) \
509 + ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
510 +
511 +/* AVR32 doesn't need any COPY relocs */
512 +#define DL_NO_COPY_RELOCS
513 +
514 +/* Return the link-time address of _DYNAMIC. Conveniently, this is the
515 + first element of the GOT. This must be inlined in a function which
516 + uses global data. */
517 +static inline Elf32_Addr
518 +elf_machine_dynamic (void)
519 +{
520 + register Elf32_Addr *got asm ("r6");
521 + return *got;
522 +}
523 +
524 +/* Return the run-time load address of the shared object. */
525 +static inline Elf32_Addr
526 +elf_machine_load_address (void)
527 +{
528 + extern void __dl_start asm("_dl_start");
529 + Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
530 + Elf32_Addr pcrel_addr;
531 +
532 + asm (" lddpc %0, 2f\n"
533 + "1: add %0, pc\n"
534 + " rjmp 3f\n"
535 + " .align 2\n"
536 + "2: .long _dl_start - 1b\n"
537 + "3:\n"
538 + : "=r"(pcrel_addr) : : "cc");
539 +
540 + return pcrel_addr - got_addr;
541 +}
542 +
543 +/*
544 + * Perform any RELATIVE relocations specified by DT_RELCOUNT.
545 + * Currently, we don't use that tag, but we might in the future as
546 + * this would reduce the startup time somewhat (although probably not by much).
547 + */
548 +static inline void
549 +elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
550 + Elf32_Word relative_count)
551 +{
552 + Elf32_Rela *rpnt = (void *)rel_addr;
553 +
554 + do {
555 + Elf32_Addr *reloc_addr;
556 + reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
557 + *reloc_addr = load_off + rpnt->r_addend;
558 + } while (--relative_count);
559 +}
560 --- /dev/null
561 +++ b/ldso/ldso/avr32/elfinterp.c
562 @@ -0,0 +1,191 @@
563 +/*
564 + * AVR32 ELF shared library loader suppport
565 + *
566 + * Copyright (C) 2004-2006 Atmel Corporation
567 + *
568 + * All rights reserved.
569 + *
570 + * Redistribution and use in source and binary forms, with or without
571 + * modification, are permitted provided that the following conditions
572 + * are met:
573 + * 1. Redistributions of source code must retain the above copyright
574 + * notice, this list of conditions and the following disclaimer.
575 + * 2. The name of the above contributors may not be
576 + * used to endorse or promote products derived from this software
577 + * without specific prior written permission.
578 + *
579 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
580 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
581 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
582 + * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
583 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
584 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
585 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
586 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
587 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
588 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
589 + * SUCH DAMAGE.
590 + */
591 +
592 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
593 +{
594 + struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
595 + Elf32_Sym *sym;
596 + unsigned long local_gotno;
597 + unsigned long gotsym;
598 + unsigned long new_addr;
599 + char *strtab, *symname;
600 + unsigned long *entry;
601 + unsigned long sym_index = got_offset / 4;
602 +
603 +#if 0
604 + local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
605 + gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
606 +
607 + sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
608 + + sym_index;
609 + strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
610 + symname = strtab + sym->st_name;
611 +
612 +#if 0
613 + new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
614 + tpnt->symbol_scope, tpnt,
615 + resolver);
616 +#endif
617 +
618 + entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
619 + *entry = new_addr;
620 +#endif
621 +
622 + return new_addr;
623 +}
624 +
625 +static int
626 +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
627 + unsigned long rel_addr, unsigned long rel_size,
628 + int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
629 + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
630 +{
631 + Elf32_Sym *symtab;
632 + Elf32_Rela *rpnt;
633 + char *strtab;
634 + int i;
635 +
636 + rpnt = (Elf32_Rela *)rel_addr;
637 + rel_size /= sizeof(Elf32_Rela);
638 + symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
639 + strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
640 +
641 + for (i = 0; i < rel_size; i++, rpnt++) {
642 + int symtab_index, res;
643 +
644 + symtab_index = ELF32_R_SYM(rpnt->r_info);
645 +
646 + debug_sym(symtab, strtab, symtab_index);
647 + debug_reloc(symtab, strtab, rpnt);
648 +
649 + res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
650 +
651 + if (res == 0)
652 + continue;
653 +
654 + _dl_dprintf(2, "\n%s: ", _dl_progname);
655 +
656 + if (symtab_index)
657 + _dl_dprintf(2, "symbol '%s': ",
658 + strtab + symtab[symtab_index].st_name);
659 +
660 + if (res < 0) {
661 + int reloc_type = ELF32_R_TYPE(rpnt->r_info);
662 +#if defined(__SUPPORT_LD_DEBUG__)
663 + _dl_dprintf(2, "can't handle reloc type %s\n",
664 + _dl_reltypes(reloc_type));
665 +#else
666 + _dl_dprintf(2, "can't handle reloc type %x\n",
667 + reloc_type);
668 +#endif
669 + _dl_exit(-res);
670 + } else {
671 + _dl_dprintf(2, "can't resolve symbol\n");
672 + return res;
673 + }
674 + }
675 +
676 + return 0;
677 +}
678 +
679 +static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
680 + Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
681 +{
682 + int reloc_type;
683 + int symtab_index;
684 + char *symname;
685 + unsigned long *reloc_addr;
686 + unsigned long symbol_addr;
687 +#if defined(__SUPPORT_LD_DEBUG__)
688 + unsigned long old_val;
689 +#endif
690 +
691 + reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
692 + reloc_type = ELF32_R_TYPE(rpnt->r_info);
693 + symtab_index = ELF32_R_SYM(rpnt->r_info);
694 + symbol_addr = 0;
695 + symname = strtab + symtab[symtab_index].st_name;
696 +
697 + if (symtab_index) {
698 + symbol_addr = (unsigned long)
699 + _dl_find_hash(strtab + symtab[symtab_index].st_name,
700 + tpnt->symbol_scope, tpnt,
701 + elf_machine_type_class(reloc_type));
702 +
703 + /* Allow undefined references to weak symbols */
704 + if (!symbol_addr &&
705 + ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
706 + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
707 + _dl_progname, symname);
708 + return 0;
709 + }
710 + }
711 +
712 +#if defined(__SUPPORT_LD_DEBUG__)
713 + old_val = *reloc_addr;
714 +#endif
715 + switch (reloc_type) {
716 + case R_AVR32_NONE:
717 + break;
718 + case R_AVR32_GLOB_DAT:
719 + case R_AVR32_JMP_SLOT:
720 + *reloc_addr = symbol_addr + rpnt->r_addend;
721 + break;
722 + case R_AVR32_RELATIVE:
723 + *reloc_addr = (unsigned long)tpnt->loadaddr
724 + + rpnt->r_addend;
725 + break;
726 + default:
727 + return -1;
728 + }
729 +
730 +#if defined(__SUPPORT_LD_DEBUG__)
731 + if (_dl_debug_reloc && _dl_debug_detail)
732 + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
733 + old_val, *reloc_addr);
734 +#endif
735 +
736 + return 0;
737 +}
738 +
739 +void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
740 + unsigned long rel_addr,
741 + unsigned long rel_size)
742 +{
743 + /* TODO: Might want to support this in order to get faster
744 + * startup times... */
745 +}
746 +
747 +int _dl_parse_relocation_information(struct dyn_elf *rpnt,
748 + unsigned long rel_addr,
749 + unsigned long rel_size)
750 +{
751 + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
752 + _dl_do_reloc);
753 +}
754 --- /dev/null
755 +++ b/ldso/ldso/avr32/resolve.S
756 @@ -0,0 +1,28 @@
757 +/*
758 + * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
759 + * indicated in register r12 and jumps to the resolved address.
760 + *
761 + * This file is subject to the terms and conditions of the GNU Lesser General
762 + * Public License. See the file "COPYING.LIB" in the main directory of this
763 + * archive for more details.
764 + *
765 + * Copyright (C) 2004-2007 Atmel Corporation
766 + */
767 +
768 +#define ip r5
769 +
770 + .text
771 + .global _dl_linux_resolve
772 + .type _dl_linux_resolve,@function
773 +_dl_linux_resolve:
774 + /* The PLT code pushed r8 for us. It contains the address of this
775 + function's GOT entry, that is entry 0. ip contains the address
776 + of the GOT entry of the function we wanted to call. */
777 + stm --sp, r9-r12, lr
778 + mov r11, r8
779 + sub r12, ip, r8
780 + rcall _dl_linux_resolver
781 + mov ip, r12
782 + popm r8-r12,lr
783 + mov pc, ip
784 + .size _dl_linux_resolve, . - _dl_linux_resolve
785 --- a/ldso/ldso/dl-startup.c
786 +++ b/ldso/ldso/dl-startup.c
787 @@ -217,7 +217,9 @@ DL_START(unsigned long args)
788 /* some arches (like MIPS) we have to tweak the GOT before relocations */
789 PERFORM_BOOTSTRAP_GOT(tpnt);
790
791 -#else
792 +#endif
793 +
794 +#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
795
796 /* OK, now do the relocations. We do not do a lazy binding here, so
797 that once we are done, we have considerably more flexibility. */
798 --- a/libc/inet/resolv.c
799 +++ b/libc/inet/resolv.c
800 @@ -1643,7 +1643,7 @@ int attribute_hidden __read_etc_hosts_r(
801 *result=result_buf;
802 ret=NETDB_SUCCESS;
803 #ifdef __UCLIBC_HAS_IPV6__
804 - } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
805 + } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
806 DPRINTF("Found INET6\n");
807 addr_list6[0] = in6;
808 addr_list6[1] = 0;
809 @@ -1658,8 +1658,8 @@ int attribute_hidden __read_etc_hosts_r(
810 } else {
811 DPRINTF("Error\n");
812 ret=TRY_AGAIN;
813 - break; /* bad ip address */
814 - }
815 + continue; /* bad ip address, keep searching */
816 + }
817
818 if (action!=GETHOSTENT) {
819 fclose(fp);
820 --- /dev/null
821 +++ b/libc/string/avr32/Makefile
822 @@ -0,0 +1,26 @@
823 +# Makefile for uClibc
824 +#
825 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
826 +#
827 +# This program is free software; you can redistribute it and/or modify it under
828 +# the terms of the GNU Library General Public License as published by the Free
829 +# Software Foundation; either version 2 of the License, or (at your option) any
830 +# later version.
831 +#
832 +# This program is distributed in the hope that it will be useful, but WITHOUT
833 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
834 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
835 +# details.
836 +#
837 +# You should have received a copy of the GNU Library General Public License
838 +# along with this program; if not, write to the Free Software Foundation, Inc.,
839 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
840 +
841 +top_srcdir := ../../../
842 +top_builddir := ../../../
843 +
844 +all: objs
845 +
846 +include $(top_builddir)Rules.mak
847 +include ../Makefile.in
848 +include $(top_srcdir)Makerules
849 --- /dev/null
850 +++ b/libc/string/avr32/bcopy.S
851 @@ -0,0 +1,26 @@
852 +/*
853 + * Copyright (C) 2004-2007 Atmel Corporation
854 + *
855 + * This file is subject to the terms and conditions of the GNU Lesser General
856 + * Public License. See the file "COPYING.LIB" in the main directory of this
857 + * archive for more details.
858 + */
859 +
860 +#include <features.h>
861 +
862 +#ifdef __UCLIBC_SUSV3_LEGACY__
863 +
864 + .text
865 + .global bcopy
866 + .type bcopy, @function
867 + .align 1
868 +bcopy:
869 + /* Swap the first two arguments */
870 + eor r11, r12
871 + eor r12, r11
872 + eor r11, r12
873 + rjmp __GI_memmove
874 +
875 + .size bcopy, . - bcopy
876 +
877 +#endif /* __UCLIBC_SUSV3_LEGACY__ */
878 --- /dev/null
879 +++ b/libc/string/avr32/bzero.S
880 @@ -0,0 +1,22 @@
881 +/*
882 + * Copyright (C) 2004-2007 Atmel Corporation
883 + *
884 + * This file is subject to the terms and conditions of the GNU Lesser General
885 + * Public License. See the file "COPYING.LIB" in the main directory of this
886 + * archive for more details.
887 + */
888 +
889 +#ifdef __UCLIBC_SUSV3_LEGACY__
890 +
891 + .text
892 + .global bzero
893 + .type bzero, @function
894 + .align 1
895 +bzero:
896 + mov r10, r11
897 + mov r11, 0
898 + rjmp __memset
899 +
900 + .size bzero, . - bzero
901 +
902 +#endif /* __UCLIBC_SUSV3_LEGACY__ */
903 --- /dev/null
904 +++ b/libc/string/avr32/memcmp.S
905 @@ -0,0 +1,61 @@
906 +/*
907 + * Copyright (C) 2004-2007 Atmel Corporation
908 + *
909 + * This file is subject to the terms and conditions of the GNU Lesser General
910 + * Public License. See the file "COPYING.LIB" in the main directory of this
911 + * archive for more details.
912 + */
913 +
914 +#include <features.h>
915 +
916 +#define s1 r12
917 +#define s2 r11
918 +#define len r10
919 +
920 + .text
921 + .global memcmp
922 + .type memcmp, @function
923 + .align 1
924 +memcmp:
925 + sub len, 4
926 + brlt .Lless_than_4
927 +
928 +1: ld.w r8, s1++
929 + ld.w r9, s2++
930 + cp.w r8, r9
931 + brne .Lfound_word
932 + sub len, 4
933 + brge 1b
934 +
935 +.Lless_than_4:
936 + sub len, -4
937 + reteq 0
938 +
939 +1: ld.ub r8, s1++
940 + ld.ub r9, s2++
941 + sub r8, r9
942 + retne r8
943 + sub len, 1
944 + brgt 1b
945 +
946 + retal 0
947 +
948 +.Lfound_word:
949 + mov len, 4
950 +
951 +2: bfextu r11, r9, 24, 8
952 + bfextu r12, r8, 24, 8
953 + sub r12, r11
954 + retne r12
955 + lsl r8, 8
956 + lsl r9, 8
957 + sub len, 1
958 + brne 2b
959 + retal r12
960 +
961 + .size memcmp, . - memcmp
962 +
963 +libc_hidden_def(memcmp)
964 +#ifdef __UCLIBC_SUSV3_LEGACY__
965 +strong_alias(memcmp,bcmp)
966 +#endif
967 --- /dev/null
968 +++ b/libc/string/avr32/memcpy.S
969 @@ -0,0 +1,111 @@
970 +/*
971 + * Copyright (C) 2004-2007 Atmel Corporation
972 + *
973 + * This file is subject to the terms and conditions of the GNU Lesser General
974 + * Public License. See the file "COPYING.LIB" in the main directory of this
975 + * archive for more details.
976 + */
977 +
978 +/* Don't use r12 as dst since we must return it unmodified */
979 +#define dst r9
980 +#define src r11
981 +#define len r10
982 +
983 + .text
984 + .global memcpy
985 + .type memcpy, @function
986 +memcpy:
987 + pref src[0]
988 + mov dst, r12
989 +
990 + /* If we have less than 32 bytes, don't do anything fancy */
991 + cp.w len, 32
992 + brge .Lmore_than_31
993 +
994 + sub len, 1
995 + retlt r12
996 +1: ld.ub r8, src++
997 + st.b dst++, r8
998 + sub len, 1
999 + brge 1b
1000 + retal r12
1001 +
1002 +.Lmore_than_31:
1003 + pushm r0-r7, lr
1004 +
1005 + /* Check alignment */
1006 + mov r8, src
1007 + andl r8, 31, COH
1008 + brne .Lunaligned_src
1009 + mov r8, dst
1010 + andl r8, 3, COH
1011 + brne .Lunaligned_dst
1012 +
1013 +.Laligned_copy:
1014 + sub len, 32
1015 + brlt .Lless_than_32
1016 +
1017 +1: /* Copy 32 bytes at a time */
1018 + ldm src, r0-r7
1019 + sub src, -32
1020 + stm dst, r0-r7
1021 + sub dst, -32
1022 + sub len, 32
1023 + brge 1b
1024 +
1025 +.Lless_than_32:
1026 + /* Copy 16 more bytes if possible */
1027 + sub len, -16
1028 + brlt .Lless_than_16
1029 + ldm src, r0-r3
1030 + sub src, -16
1031 + sub len, 16
1032 + stm dst, r0-r3
1033 + sub dst, -16
1034 +
1035 +.Lless_than_16:
1036 + /* Do the remaining as byte copies */
1037 + neg len
1038 + add pc, pc, len << 2
1039 + .rept 15
1040 + ld.ub r0, src++
1041 + st.b dst++, r0
1042 + .endr
1043 +
1044 + popm r0-r7, pc
1045 +
1046 +.Lunaligned_src:
1047 + /* Make src cacheline-aligned. r8 = (src & 31) */
1048 + rsub r8, r8, 32
1049 + sub len, r8
1050 +1: ld.ub r0, src++
1051 + st.b dst++, r0
1052 + sub r8, 1
1053 + brne 1b
1054 +
1055 + /* If dst is word-aligned, we're ready to go */
1056 + pref src[0]
1057 + mov r8, 3
1058 + tst dst, r8
1059 + breq .Laligned_copy
1060 +
1061 +.Lunaligned_dst:
1062 + /* src is aligned, but dst is not. Expect bad performance */
1063 + sub len, 4
1064 + brlt 2f
1065 +1: ld.w r0, src++
1066 + st.w dst++, r0
1067 + sub len, 4
1068 + brge 1b
1069 +
1070 +2: neg len
1071 + add pc, pc, len << 2
1072 + .rept 3
1073 + ld.ub r0, src++
1074 + st.b dst++, r0
1075 + .endr
1076 +
1077 + popm r0-r7, pc
1078 + .size memcpy, . - memcpy
1079 +
1080 +libc_hidden_def(memcpy)
1081 --- /dev/null
1082 +++ b/libc/string/avr32/memmove.S
1083 @@ -0,0 +1,116 @@
1084 +/*
1085 + * Copyright (C) 2004-2007 Atmel Corporation
1086 + *
1087 + * This file is subject to the terms and conditions of the GNU Lesser General
1088 + * Public License. See the file "COPYING.LIB" in the main directory of this
1089 + * archive for more details.
1090 + */
1091 +
1092 +#define dst r12
1093 +#define src r11
1094 +#define len r10
1095 +
1096 + .text
1097 + .global memmove
1098 + .type memmove, @function
1099 +memmove:
1100 + cp.w src, dst
1101 + brge __GI_memcpy
1102 +
1103 + add dst, len
1104 + add src, len
1105 + pref src[-1]
1106 +
1107 + /*
1108 + * The rest is basically the same as in memcpy.S except that
1109 + * the direction is reversed.
1110 + */
1111 + cp.w len, 32
1112 + brge .Lmore_than_31
1113 +
1114 + sub len, 1
1115 + retlt r12
1116 +1: ld.ub r8, --src
1117 + st.b --dst, r8
1118 + sub len, 1
1119 + brge 1b
1120 + retal r12
1121 +
1122 +.Lmore_than_31:
1123 + pushm r0-r7, lr
1124 +
1125 + /* Check alignment */
1126 + mov r8, src
1127 + andl r8, 31, COH
1128 + brne .Lunaligned_src
1129 + mov r8, r12
1130 + andl r8, 3, COH
1131 + brne .Lunaligned_dst
1132 +
1133 +.Laligned_copy:
1134 + sub len, 32
1135 + brlt .Lless_than_32
1136 +
1137 +1: /* Copy 32 bytes at a time */
1138 + sub src, 32
1139 + ldm src, r0-r7
1140 + sub dst, 32
1141 + sub len, 32
1142 + stm dst, r0-r7
1143 + brge 1b
1144 +
1145 +.Lless_than_32:
1146 + /* Copy 16 more bytes if possible */
1147 + sub len, -16
1148 + brlt .Lless_than_16
1149 + sub src, 16
1150 + ldm src, r0-r3
1151 + sub dst, 16
1152 + sub len, 16
1153 + stm dst, r0-r3
1154 +
1155 +.Lless_than_16:
1156 + /* Do the remaining as byte copies */
1157 + sub len, -16
1158 + breq 2f
1159 +1: ld.ub r0, --src
1160 + st.b --dst, r0
1161 + sub len, 1
1162 + brne 1b
1163 +
1164 +2: popm r0-r7, pc
1165 +
1166 +.Lunaligned_src:
1167 + /* Make src cacheline-aligned. r8 = (src & 31) */
1168 + sub len, r8
1169 +1: ld.ub r0, --src
1170 + st.b --dst, r0
1171 + sub r8, 1
1172 + brne 1b
1173 +
1174 + /* If dst is word-aligned, we're ready to go */
1175 + pref src[-4]
1176 + mov r8, 3
1177 + tst dst, r8
1178 + breq .Laligned_copy
1179 +
1180 +.Lunaligned_dst:
1181 + /* src is aligned, but dst is not. Expect bad performance */
1182 + sub len, 4
1183 + brlt 2f
1184 +1: ld.w r0, --src
1185 + st.w --dst, r0
1186 + sub len, 4
1187 + brge 1b
1188 +
1189 +2: neg len
1190 + add pc, pc, len << 2
1191 + .rept 3
1192 + ld.ub r0, --src
1193 + st.b --dst, r0
1194 + .endr
1195 +
1196 + popm r0-r7, pc
1197 + .size memmove, . - memmove
1198 +
1199 +libc_hidden_def(memmove)
1200 --- /dev/null
1201 +++ b/libc/string/avr32/memset.S
1202 @@ -0,0 +1,70 @@
1203 +/*
1204 + * Copyright (C) 2004-2007 Atmel Corporation
1205 + *
1206 + * This file is subject to the terms and conditions of the GNU Lesser General
1207 + * Public License. See the file "COPYING.LIB" in the main directory of this
1208 + * archive for more details.
1209 + */
1210 +
1211 +#include <features.h>
1212 +
1213 +#define s r12
1214 +#define c r11
1215 +#define n r10
1216 +
1217 + .text
1218 + .global memset
1219 + .type memset, @function
1220 +
1221 + .global __memset
1222 + .hidden __memset
1223 + .type __memset, @function
1224 +
1225 + .align 1
1226 +memset:
1227 +__memset:
1228 + cp.w n, 32
1229 + mov r9, s
1230 + brge .Llarge_memset
1231 +
1232 + sub n, 1
1233 + retlt s
1234 +1: st.b s++, c
1235 + sub n, 1
1236 + brge 1b
1237 +
1238 + retal r9
1239 +
1240 +.Llarge_memset:
1241 + mov r8, r11
1242 + mov r11, 3
1243 + bfins r8, r8, 8, 8
1244 + bfins r8, r8, 16, 16
1245 + tst s, r11
1246 + breq 2f
1247 +
1248 +1: st.b s++, r8
1249 + sub n, 1
1250 + tst s, r11
1251 + brne 1b
1252 +
1253 +2: mov r11, r9
1254 + mov r9, r8
1255 + sub n, 8
1256 +
1257 +3: st.d s++, r8
1258 + sub n, 8
1259 + brge 3b
1260 +
1261 + /* If we are done, n == -8 and we'll skip all st.b insns below */
1262 + neg n
1263 + lsl n, 1
1264 + add pc, n
1265 + .rept 7
1266 + st.b s++, r8
1267 + .endr
1268 + retal r11
1269 +
1270 + .size memset, . - memset
1271 +
1272 +libc_hidden_def(memset)
1273 --- /dev/null
1274 +++ b/libc/string/avr32/strcmp.S
1275 @@ -0,0 +1,91 @@
1276 +/*
1277 + * Copyright (C) 2004-2007 Atmel Corporation
1278 + *
1279 + * This file is subject to the terms and conditions of the GNU Lesser General
1280 + * Public License. See the file "COPYING.LIB" in the main directory of this
1281 + * archive for more details.
1282 + */
1283 +
1284 +#include <features.h>
1285 +
1286 +#define s1 r12
1287 +#define s2 r11
1288 +#define len r10
1289 +
1290 + .text
1291 + .global strcmp
1292 + .type strcmp, @function
1293 + .align 1
1294 +strcmp:
1295 + mov r8, 3
1296 + tst s1, r8
1297 + brne .Lunaligned_s1
1298 + tst s2, r8
1299 + brne .Lunaligned_s2
1300 +
1301 +1: ld.w r8, s1++
1302 + ld.w r9, s2++
1303 + cp.w r8, r9
1304 + brne 2f
1305 + tnbz r8
1306 + brne 1b
1307 + retal 0
1308 +
1309 +2: bfextu r12, r8, 24, 8
1310 + bfextu r11, r9, 24, 8
1311 + sub r12, r11
1312 + retne r12
1313 + cp.w r11, 0
1314 + reteq 0
1315 + bfextu r12, r8, 16, 8
1316 + bfextu r11, r9, 16, 8
1317 + sub r12, r11
1318 + retne r12
1319 + cp.w r11, 0
1320 + reteq 0
1321 + bfextu r12, r8, 8, 8
1322 + bfextu r11, r9, 8, 8
1323 + sub r12, r11
1324 + retne r12
1325 + cp.w r11, 0
1326 + reteq 0
1327 + bfextu r12, r8, 0, 8
1328 + bfextu r11, r9, 0, 8
1329 + sub r12, r11
1330 + retal r12
1331 +
1332 +.Lunaligned_s1:
1333 +3: tst s1, r8
1334 + breq 4f
1335 + ld.ub r10, s1++
1336 + ld.ub r9, s2++
1337 + sub r10, r9
1338 + retne r10
1339 + cp.w r9, 0
1340 + brne 3b
1341 + retal r10
1342 +
1343 +4: tst s2, r8
1344 + breq 1b
1345 +
1346 +.Lunaligned_s2:
1347 + /*
1348 + * s1 and s2 can't both be aligned, and unaligned word loads
1349 + * can trigger spurious exceptions if we cross a page boundary.
1350 + * Do it the slow way...
1351 + */
1352 +1: ld.ub r8, s1++
1353 + ld.ub r9, s2++
1354 + sub r8, r9
1355 + retne r8
1356 + cp.w r9, 0
1357 + brne 1b
1358 + retal 0
1359 +
1360 + .size strcmp, . - strcmp
1361 +
1362 +libc_hidden_def(strcmp)
1363 +#ifndef __UCLIBC_HAS_LOCALE__
1364 +strong_alias(strcmp, strcoll)
1365 +libc_hidden_def(strcoll)
1366 +#endif
1367 --- /dev/null
1368 +++ b/libc/string/avr32/strlen.S
1369 @@ -0,0 +1,62 @@
1370 +/*
1371 + * Copyright (C) 2004-2007 Atmel Corporation
1372 + *
1373 + * This file is subject to the terms and conditions of the GNU Lesser General
1374 + * Public License. See the file "COPYING.LIB" in the main directory of this
1375 + * archive for more details.
1376 + */
1377 +
1378 +#include <features.h>
1379 +
1380 +#define str r12
1381 +
1382 + .text
1383 + .global strlen
1384 + .type strlen, @function
1385 +strlen:
1386 + mov r11, r12
1387 +
1388 + mov r9, str
1389 + andl r9, 3, COH
1390 + brne .Lunaligned_str
1391 +
1392 +1: ld.w r8, str++
1393 + tnbz r8
1394 + brne 1b
1395 +
1396 + sub r12, r11
1397 + bfextu r9, r8, 24, 8
1398 + cp.w r9, 0
1399 + subeq r12, 4
1400 + reteq r12
1401 + bfextu r9, r8, 16, 8
1402 + cp.w r9, 0
1403 + subeq r12, 3
1404 + reteq r12
1405 + bfextu r9, r8, 8, 8
1406 + cp.w r9, 0
1407 + subeq r12, 2
1408 + reteq r12
1409 + sub r12, 1
1410 + retal r12
1411 +
1412 +.Lunaligned_str:
1413 + add pc, pc, r9 << 3
1414 + sub r0, r0, 0 /* 4-byte nop */
1415 + ld.ub r8, str++
1416 + sub r8, r8, 0
1417 + breq 1f
1418 + ld.ub r8, str++
1419 + sub r8, r8, 0
1420 + breq 1f
1421 + ld.ub r8, str++
1422 + sub r8, r8, 0
1423 + brne 1b
1424 +
1425 +1: sub r12, 1
1426 + sub r12, r11
1427 + retal r12
1428 +
1429 + .size strlen, . - strlen
1430 +
1431 +libc_hidden_def(strlen)
1432 --- /dev/null
1433 +++ b/libc/sysdeps/linux/avr32/Makefile
1434 @@ -0,0 +1,25 @@
1435 +# Makefile for uClibc
1436 +#
1437 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
1438 +#
1439 +# This program is free software; you can redistribute it and/or modify it under
1440 +# the terms of the GNU Library General Public License as published by the Free
1441 +# Software Foundation; either version 2 of the License, or (at your option) any
1442 +# later version.
1443 +#
1444 +# This program is distributed in the hope that it will be useful, but WITHOUT
1445 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1446 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
1447 +# details.
1448 +#
1449 +# You should have received a copy of the GNU Library General Public License
1450 +# along with this program; if not, write to the Free Software Foundation, Inc.,
1451 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1452 +
1453 +top_srcdir=../../../../
1454 +top_builddir=../../../../
1455 +all: objs
1456 +
1457 +include $(top_builddir)Rules.mak
1458 +include Makefile.arch
1459 +include $(top_srcdir)Makerules
1460 --- /dev/null
1461 +++ b/libc/sysdeps/linux/avr32/Makefile.arch
1462 @@ -0,0 +1,13 @@
1463 +# Makefile for uClibc
1464 +#
1465 +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
1466 +#
1467 +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
1468 +#
1469 +
1470 +CSRC := brk.c clone.c mmap.c sigaction.c
1471 +
1472 +SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
1473 + sigrestorer.S syscall.S vfork.S
1474 +
1475 +include $(top_srcdir)/libc/sysdeps/linux/Makefile.commonarch
1476 --- /dev/null
1477 +++ b/libc/sysdeps/linux/avr32/__longjmp.S
1478 @@ -0,0 +1,21 @@
1479 +/*
1480 + * Copyright (C) 2004-2007 Atmel Corporation
1481 + *
1482 + * This file is subject to the terms and conditions of the GNU Lesser General
1483 + * Public License. See the file "COPYING.LIB" in the main directory of this
1484 + * archive for more details.
1485 + */
1486 +
1487 + .global __longjmp
1488 + .type __longjmp,"function"
1489 + .align 1
1490 +__longjmp:
1491 + ldm r12++, r0-r8,sp,lr
1492 + mustr r8 /* restore status register (lower half) */
1493 + cp r11, 0 /* can't return zero */
1494 + frs
1495 + moveq r11, 1
1496 + retal r11
1497 + .size __longjmp, . - __longjmp
1498 +
1499 +libc_hidden_def(__longjmp)
1500 --- /dev/null
1501 +++ b/libc/sysdeps/linux/avr32/bits/atomic.h
1502 @@ -0,0 +1,120 @@
1503 +/*
1504 + * Copyright (C) 2007 Atmel Corporation
1505 + *
1506 + * This file is subject to the terms and conditions of the GNU Lesser General
1507 + * Public License. See the file "COPYING.LIB" in the main directory of this
1508 + * archive for more details.
1509 + */
1510 +#ifndef _AVR32_BITS_ATOMIC_H
1511 +#define _AVR32_BITS_ATOMIC_H 1
1512 +
1513 +#include <inttypes.h>
1514 +
1515 +typedef int32_t atomic32_t;
1516 +typedef uint32_t uatomic32_t;
1517 +typedef int_fast32_t atomic_fast32_t;
1518 +typedef uint_fast32_t uatomic_fast32_t;
1519 +
1520 +typedef intptr_t atomicptr_t;
1521 +typedef uintptr_t uatomicptr_t;
1522 +typedef intmax_t atomic_max_t;
1523 +typedef uintmax_t uatomic_max_t;
1524 +
1525 +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
1526 + (abort(), 0)
1527 +
1528 +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
1529 + (abort(), 0)
1530 +
1531 +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
1532 + ({ \
1533 + __typeof__(*(mem)) __prev; \
1534 + __asm__ __volatile__( \
1535 + "/* __arch_compare_and_exchange_val_32_acq */\n" \
1536 + "1: ssrf 5\n" \
1537 + " ld.w %[result], %[m]\n" \
1538 + " cp.w %[result], %[old]\n" \
1539 + " brne 2f\n" \
1540 + " stcond %[m], %[new]\n" \
1541 + " brne 1b\n" \
1542 + "2:" \
1543 + : [result] "=&r"(__result), [m] "=m"(*(mem)) \
1544 + : "m"(*(mem)), [old] "ir"(oldval), \
1545 + [new] "r"(newval) \
1546 + : "memory", "cc"); \
1547 + __prev; \
1548 + })
1549 +
1550 +#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
1551 + (abort(), 0)
1552 +
1553 +#define __arch_exchange_32_acq(mem, newval) \
1554 + ({ \
1555 + __typeof__(*(mem)) __oldval; \
1556 + __asm__ __volatile__( \
1557 + "/*__arch_exchange_32_acq */\n" \
1558 + " xchg %[old], %[m], %[new]" \
1559 + : [old] "=&r"(__oldval) \
1560 + : [m] "r"(mem), [new] "r"(newval) \
1561 + : "memory"); \
1562 + __oldval; \
1563 + })
1564 +
1565 +#define __arch_atomic_exchange_and_add_32(mem, value) \
1566 + ({ \
1567 + __typeof__(*(mem)) __oldval, __tmp; \
1568 + __asm__ __volatile__( \
1569 + "/* __arch_atomic_exchange_and_add_32 */\n" \
1570 + "1: ssrf 5\n" \
1571 + " ld.w %[old], %[m]\n" \
1572 + " add %[tmp], %[old], %[val]\n" \
1573 + " stcond %[m], %[tmp]\n" \
1574 + " brne 1b" \
1575 + : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
1576 + [m] "=m"(*(mem)) \
1577 + : "m"(*(mem)), [val] "r"(value) \
1578 + : "memory", "cc"); \
1579 + __oldval; \
1580 + })
1581 +
1582 +#define __arch_atomic_decrement_if_positive_32(mem) \
1583 + ({ \
1584 + __typeof__(*(mem)) __oldval, __tmp; \
1585 + __asm__ __volatile__( \
1586 + "/* __arch_atomic_decrement_if_positive_32 */\n" \
1587 + "1: ssrf 5\n" \
1588 + " ld.w %[old], %[m]\n" \
1589 + " sub %[tmp], %[old], 1\n" \
1590 + " brlt 2f\n" \
1591 + " stcond %[m], %[tmp]\n" \
1592 + " brne 1b" \
1593 + "2:" \
1594 + : [old] "=&r"(__oldval), [tmp] "=&r"(__tmp), \
1595 + [m] "=m"(*(mem)) \
1596 + : "m"(*(mem)) \
1597 + : "memory", "cc"); \
1598 + __oldval; \
1599 + })
1600 +
1601 +#define atomic_exchange_acq(mem, newval) \
1602 + ({ \
1603 + if (sizeof(*(mem)) != 4) \
1604 + abort(); \
1605 + __arch_exchange_32_acq(mem, newval); \
1606 + })
1607 +
1608 +#define atomic_exchange_and_add(mem, newval) \
1609 + ({ \
1610 + if (sizeof(*(mem)) != 4) \
1611 + abort(); \
1612 + __arch_atomic_exchange_and_add_32(mem, newval); \
1613 + })
1614 +
1615 +#define atomic_decrement_if_positive(mem) \
1616 + ({ \
1617 + if (sizeof(*(mem)) != 4) \
1618 + abort(); \
1619 + __arch_atomic_decrement_if_positive_32(mem); \
1620 + })
1621 +
1622 +#endif /* _AVR32_BITS_ATOMIC_H */
1623 --- /dev/null
1624 +++ b/libc/sysdeps/linux/avr32/bits/byteswap.h
1625 @@ -0,0 +1,70 @@
1626 +/*
1627 + * Copyright (C) 2005 Atmel Corporation
1628 + *
1629 + * This file is subject to the terms and conditions of the GNU Lesser General
1630 + * Public License. See the file "COPYING.LIB" in the main directory of this
1631 + * archive for more details.
1632 + */
1633 +
1634 +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
1635 +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
1636 +#endif
1637 +
1638 +#ifndef _BITS_BYTESWAP_H
1639 +#define _BITS_BYTESWAP_H 1
1640 +
1641 +/* Swap bytes in 16 bit value. */
1642 +#if defined __GNUC__
1643 +# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
1644 +#else
1645 +/* This is better than nothing. */
1646 +static __inline unsigned short int
1647 +__bswap_16 (unsigned short int __bsx)
1648 +{
1649 + return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
1650 +}
1651 +#endif
1652 +
1653 +/* Swap bytes in 32 bit value. */
1654 +#if defined __GNUC__
1655 +# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
1656 +#else
1657 +static __inline unsigned int
1658 +__bswap_32 (unsigned int __bsx)
1659 +{
1660 + return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
1661 + (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
1662 +}
1663 +#endif
1664 +
1665 +#if defined __GNUC__
1666 +/* Swap bytes in 64 bit value. */
1667 +# define __bswap_constant_64(x) \
1668 + ((((x) & 0xff00000000000000ull) >> 56) \
1669 + | (((x) & 0x00ff000000000000ull) >> 40) \
1670 + | (((x) & 0x0000ff0000000000ull) >> 24) \
1671 + | (((x) & 0x000000ff00000000ull) >> 8) \
1672 + | (((x) & 0x00000000ff000000ull) << 8) \
1673 + | (((x) & 0x0000000000ff0000ull) << 24) \
1674 + | (((x) & 0x000000000000ff00ull) << 40) \
1675 + | (((x) & 0x00000000000000ffull) << 56))
1676 +
1677 +# define __bswap_64(x) \
1678 + (__extension__ \
1679 + ({ \
1680 + union { \
1681 + __extension__ unsigned long long int __ll; \
1682 + unsigned int __l[2]; \
1683 + } __w, __r; \
1684 + if (__builtin_constant_p(x)) \
1685 + __r.__ll = __bswap_constant_64(x); \
1686 + else { \
1687 + __w.__ll = (x); \
1688 + __r.__l[0] = __bswap_32(__w.__l[1]); \
1689 + __r.__l[1] = __bswap_32(__w.__l[0]); \
1690 + } \
1691 + __r.__ll; \
1692 + }))
1693 +#endif
1694 +
1695 +#endif /* _BITS_BYTESWAP_H */
1696 --- /dev/null
1697 +++ b/libc/sysdeps/linux/avr32/bits/endian.h
1698 @@ -0,0 +1,7 @@
1699 +/* AVR32 is big-endian */
1700 +
1701 +#ifndef _ENDIAN_H
1702 +# error "Never use <bits/endian.h> directly; include <endian.h> instead."
1703 +#endif
1704 +
1705 +#define __BYTE_ORDER __BIG_ENDIAN
1706 --- /dev/null
1707 +++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
1708 @@ -0,0 +1,165 @@
1709 +#ifndef _FCNTL_H
1710 +# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
1711 +#endif
1712 +
1713 +#include <sys/types.h>
1714 +
1715 +/*
1716 + * open/fcntl - O_SYNC is only implemented on blocks devices and on files
1717 + * located on an ext2 file system
1718 + */
1719 +#define O_ACCMODE 00000003
1720 +#define O_RDONLY 00000000
1721 +#define O_WRONLY 00000001
1722 +#define O_RDWR 00000002
1723 +#define O_CREAT 00000100 /* not fcntl */
1724 +#define O_EXCL 00000200 /* not fcntl */
1725 +#define O_NOCTTY 00000400 /* not fcntl */
1726 +#define O_TRUNC 00001000 /* not fcntl */
1727 +#define O_APPEND 00002000
1728 +#define O_NONBLOCK 00004000
1729 +#define O_NDELAY O_NONBLOCK
1730 +#define O_SYNC 00010000
1731 +#define O_ASYNC 00020000
1732 +
1733 +#ifdef __USE_GNU
1734 +# define O_DIRECT 00040000 /* must be a directory */
1735 +# define O_DIRECTORY 00200000 /* direct disk access */
1736 +# define O_NOFOLLOW 00400000 /* don't follow links */
1737 +# define O_NOATIME 01000000 /* don't set atime */
1738 +#endif
1739 +
1740 +#ifdef __USE_LARGEFILE64
1741 +# define O_LARGEFILE 00100000
1742 +#endif
1743 +
1744 +/* For now Linux has synchronisity options for data and read operations.
1745 + We define the symbols here but let them do the same as O_SYNC since
1746 + this is a superset. */
1747 +#if defined __USE_POSIX199309 || defined __USE_UNIX98
1748 +# define O_DSYNC O_SYNC /* Synchronize data. */
1749 +# define O_RSYNC O_SYNC /* Synchronize read operations. */
1750 +#endif
1751 +
1752 +#define F_DUPFD 0 /* dup */
1753 +#define F_GETFD 1 /* get close_on_exec */
1754 +#define F_SETFD 2 /* set/clear close_on_exec */
1755 +#define F_GETFL 3 /* get file->f_flags */
1756 +#define F_SETFL 4 /* set file->f_flags */
1757 +
1758 +#ifndef __USE_FILE_OFFSET64
1759 +# define F_GETLK 5
1760 +# define F_SETLK 6
1761 +# define F_SETLKW 7
1762 +#else
1763 +# define F_GETLK F_GETLK64
1764 +# define F_SETLK F_SETLK64
1765 +# define F_SETLKW F_SETLKW64
1766 +#endif
1767 +#define F_GETLK64 12 /* using 'struct flock64' */
1768 +#define F_SETLK64 13
1769 +#define F_SETLKW64 14
1770 +
1771 +#if defined __USE_BSD || defined __USE_XOPEN2K
1772 +# define F_SETOWN 8 /* for sockets. */
1773 +# define F_GETOWN 9 /* for sockets. */
1774 +#endif
1775 +
1776 +#ifdef __USE_GNU
1777 +# define F_SETSIG 10 /* for sockets. */
1778 +# define F_GETSIG 11 /* for sockets. */
1779 +#endif
1780 +
1781 +#ifdef __USE_GNU
1782 +# define F_SETLEASE 1024 /* Set a lease. */
1783 +# define F_GETLEASE 1025 /* Enquire what lease is active. */
1784 +# define F_NOTIFY 1026 /* Request notfications on a directory. */
1785 +#endif
1786 +
1787 +/* for F_[GET|SET]FL */
1788 +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
1789 +
1790 +/* for posix fcntl() and lockf() */
1791 +#define F_RDLCK 0
1792 +#define F_WRLCK 1
1793 +#define F_UNLCK 2
1794 +
1795 +/* for old implementation of bsd flock () */
1796 +#define F_EXLCK 4 /* or 3 */
1797 +#define F_SHLCK 8 /* or 4 */
1798 +
1799 +/* for leases */
1800 +#define F_INPROGRESS 16
1801 +
1802 +#ifdef __USE_BSD
1803 +/* operations for bsd flock(), also used by the kernel implementation */
1804 +# define LOCK_SH 1 /* shared lock */
1805 +# define LOCK_EX 2 /* exclusive lock */
1806 +# define LOCK_NB 4 /* or'd with one of the above to prevent
1807 + blocking */
1808 +# define LOCK_UN 8 /* remove lock */
1809 +#endif
1810 +
1811 +#ifdef __USE_GNU
1812 +# define LOCK_MAND 32 /* This is a mandatory flock */
1813 +# define LOCK_READ 64 /* ... Which allows concurrent
1814 + read operations */
1815 +# define LOCK_WRITE 128 /* ... Which allows concurrent
1816 + write operations */
1817 +# define LOCK_RW 192 /* ... Which allows concurrent
1818 + read & write ops */
1819 +#endif
1820 +
1821 +#ifdef __USE_GNU
1822 +/* Types of directory notifications that may be requested with F_NOTIFY. */
1823 +# define DN_ACCESS 0x00000001 /* File accessed. */
1824 +# define DN_MODIFY 0x00000002 /* File modified. */
1825 +# define DN_CREATE 0x00000004 /* File created. */
1826 +# define DN_DELETE 0x00000008 /* File removed. */
1827 +# define DN_RENAME 0x00000010 /* File renamed. */
1828 +# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
1829 +# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
1830 +#endif
1831 +
1832 +struct flock {
1833 + short l_type;
1834 + short l_whence;
1835 +#ifndef __USE_FILE_OFFSET64
1836 + __off_t l_start;
1837 + __off_t l_len;
1838 +#else
1839 + __off64_t l_start;
1840 + __off64_t l_len;
1841 +#endif
1842 + __pid_t l_pid;
1843 +};
1844 +
1845 +#ifdef __USE_LARGEFILE64
1846 +struct flock64 {
1847 + short l_type;
1848 + short l_whence;
1849 + __off64_t l_start;
1850 + __off64_t l_len;
1851 + __pid_t l_pid;
1852 +};
1853 +#endif
1854 +
1855 +/* Define some more compatibility macros to be backward compatible with
1856 + * BSD systems which did not managed to hide these kernel macros. */
1857 +#ifdef __USE_BSD
1858 +# define FAPPEND O_APPEND
1859 +# define FFSYNC O_FSYNC
1860 +# define FASYNC O_ASYNC
1861 +# define FNONBLOCK O_NONBLOCK
1862 +# define FNDELAY O_NDELAY
1863 +#endif /* Use BSD. */
1864 +
1865 +/* Advise to `posix_fadvise'. */
1866 +#ifdef __USE_XOPEN2K
1867 +# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
1868 +# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
1869 +# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
1870 +# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
1871 +# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
1872 +# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
1873 +#endif
1874 --- /dev/null
1875 +++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
1876 @@ -0,0 +1,67 @@
1877 +#ifndef _BITS_STAT_STRUCT_H
1878 +#define _BITS_STAT_STRUCT_H
1879 +
1880 +#ifndef _LIBC
1881 +#error bits/kernel_stat.h is for internal uClibc use only!
1882 +#endif
1883 +
1884 +/*
1885 + * This file provides struct stat, taken from kernel 2.6.4. Verified
1886 + * to match kernel 2.6.22.
1887 + */
1888 +
1889 +struct kernel_stat {
1890 + unsigned long st_dev;
1891 + unsigned long st_ino;
1892 + unsigned short st_mode;
1893 + unsigned short st_nlink;
1894 + unsigned short st_uid;
1895 + unsigned short st_gid;
1896 + unsigned long st_rdev;
1897 + unsigned long st_size;
1898 + unsigned long st_blksize;
1899 + unsigned long st_blocks;
1900 + unsigned long st_atime;
1901 + unsigned long st_atime_nsec;
1902 + unsigned long st_mtime;
1903 + unsigned long st_mtime_nsec;
1904 + unsigned long st_ctime;
1905 + unsigned long st_ctime_nsec;
1906 + unsigned long __unused4;
1907 + unsigned long __unused5;
1908 +};
1909 +
1910 +#define STAT_HAVE_NSEC 1
1911 +
1912 +struct kernel_stat64 {
1913 + unsigned long long st_dev;
1914 +
1915 + unsigned long long st_ino;
1916 + unsigned int st_mode;
1917 + unsigned int st_nlink;
1918 +
1919 + unsigned long st_uid;
1920 + unsigned long st_gid;
1921 +
1922 + unsigned long long st_rdev;
1923 +
1924 + long long st_size;
1925 + unsigned long __pad1;
1926 + unsigned long st_blksize;
1927 +
1928 + unsigned long long st_blocks;
1929 +
1930 + unsigned long st_atime;
1931 + unsigned long st_atime_nsec;
1932 +
1933 + unsigned long st_mtime;
1934 + unsigned long st_mtime_nsec;
1935 +
1936 + unsigned long st_ctime;
1937 + unsigned long st_ctime_nsec;
1938 +
1939 + unsigned long __unused1;
1940 + unsigned long __unused2;
1941 +};
1942 +
1943 +#endif /* _BITS_STAT_STRUCT_H */
1944 --- /dev/null
1945 +++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h
1946 @@ -0,0 +1,55 @@
1947 +/* Note that we use the exact same include guard #define names
1948 + * as asm/posix_types.h. This will avoid gratuitous conflicts
1949 + * with the posix_types.h kernel header, and will ensure that
1950 + * our private content, and not the kernel header, will win.
1951 + * -Erik
1952 + */
1953 +#ifndef __ASM_AVR32_POSIX_TYPES_H
1954 +#define __ASM_AVR32_POSIX_TYPES_H
1955 +
1956 +/*
1957 + * This file is generally used by user-level software, so you need to
1958 + * be a little careful about namespace pollution etc. Also, we cannot
1959 + * assume GCC is being used.
1960 + */
1961 +
1962 +typedef unsigned long __kernel_dev_t;
1963 +typedef unsigned long __kernel_ino_t;
1964 +typedef unsigned short __kernel_mode_t;
1965 +typedef unsigned short __kernel_nlink_t;
1966 +typedef long __kernel_off_t;
1967 +typedef int __kernel_pid_t;
1968 +typedef unsigned short __kernel_ipc_pid_t;
1969 +typedef unsigned int __kernel_uid_t;
1970 +typedef unsigned int __kernel_gid_t;
1971 +typedef unsigned long __kernel_size_t;
1972 +typedef long __kernel_ssize_t;
1973 +typedef int __kernel_ptrdiff_t;
1974 +typedef long __kernel_time_t;
1975 +typedef long __kernel_suseconds_t;
1976 +typedef long __kernel_clock_t;
1977 +typedef int __kernel_timer_t;
1978 +typedef int __kernel_clockid_t;
1979 +typedef int __kernel_daddr_t;
1980 +typedef char * __kernel_caddr_t;
1981 +typedef unsigned short __kernel_uid16_t;
1982 +typedef unsigned short __kernel_gid16_t;
1983 +typedef unsigned int __kernel_uid32_t;
1984 +typedef unsigned int __kernel_gid32_t;
1985 +typedef unsigned short __kernel_old_uid_t;
1986 +typedef unsigned short __kernel_old_gid_t;
1987 +typedef unsigned short __kernel_old_dev_t;
1988 +
1989 +#ifdef __GNUC__
1990 +typedef long long __kernel_loff_t;
1991 +#endif
1992 +
1993 +typedef struct {
1994 +#if defined(__USE_ALL)
1995 + int val[2];
1996 +#else
1997 + int __val[2];
1998 +#endif
1999 +} __kernel_fsid_t;
2000 +
2001 +#endif /* __ASM_AVR32_POSIX_TYPES_H */
2002 --- /dev/null
2003 +++ b/libc/sysdeps/linux/avr32/bits/mman.h
2004 @@ -0,0 +1,103 @@
2005 +/* Definitions for POSIX memory map interface. Linux/AVR32 version.
2006 + Copyright (C) 1997, 2000 Free Software Foundation, Inc.
2007 + This file is part of the GNU C Library.
2008 +
2009 + The GNU C Library is free software; you can redistribute it and/or
2010 + modify it under the terms of the GNU Lesser General Public
2011 + License as published by the Free Software Foundation; either
2012 + version 2.1 of the License, or (at your option) any later version.
2013 +
2014 + The GNU C Library is distributed in the hope that it will be useful,
2015 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2016 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2017 + Lesser General Public License for more details.
2018 +
2019 + You should have received a copy of the GNU Lesser General Public
2020 + License along with the GNU C Library; if not, write to the Free
2021 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2022 + 02111-1307 USA. */
2023 +
2024 +#ifndef _SYS_MMAN_H
2025 +# error "Never include this file directly. Use <sys/mman.h> instead"
2026 +#endif
2027 +
2028 +/* The following definitions basically come from the kernel headers.
2029 + But the kernel header is not namespace clean. */
2030 +
2031 +
2032 +/* Protections are chosen from these bits, OR'd together. The
2033 + implementation does not necessarily support PROT_EXEC or PROT_WRITE
2034 + without PROT_READ. The only guarantees are that no writing will be
2035 + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
2036 +
2037 +#define PROT_READ 0x1 /* Page can be read. */
2038 +#define PROT_WRITE 0x2 /* Page can be written. */
2039 +#define PROT_EXEC 0x4 /* Page can be executed. */
2040 +#define PROT_NONE 0x0 /* Page can not be accessed. */
2041 +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
2042 + growsdown vma (mprotect only). */
2043 +#define PROT_GROWSUP 0x02000000 /* Extend change to start of
2044 + growsup vma (mprotect only). */
2045 +
2046 +/* Sharing types (must choose one and only one of these). */
2047 +#define MAP_SHARED 0x01 /* Share changes. */
2048 +#define MAP_PRIVATE 0x02 /* Changes are private. */
2049 +#ifdef __USE_MISC
2050 +# define MAP_TYPE 0x0f /* Mask for type of mapping. */
2051 +#endif
2052 +
2053 +/* Other flags. */
2054 +#define MAP_FIXED 0x10 /* Interpret addr exactly. */
2055 +#ifdef __USE_MISC
2056 +# define MAP_FILE 0
2057 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
2058 +# define MAP_ANON MAP_ANONYMOUS
2059 +#endif
2060 +
2061 +/* These are Linux-specific. */
2062 +#ifdef __USE_MISC
2063 +# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */
2064 +# define MAP_DENYWRITE 0x0800 /* ETXTBSY */
2065 +# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */
2066 +# define MAP_LOCKED 0x2000 /* Lock the mapping. */
2067 +# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */
2068 +# define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
2069 +# define MAP_NONBLOCK 0x10000 /* do not block on IO */
2070 +#endif
2071 +
2072 +/* Flags to `msync'. */
2073 +#define MS_ASYNC 1 /* Sync memory asynchronously. */
2074 +#define MS_SYNC 4 /* Synchronous memory sync. */
2075 +#define MS_INVALIDATE 2 /* Invalidate the caches. */
2076 +
2077 +/* Flags for `mlockall'. */
2078 +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
2079 +#define MCL_FUTURE 2 /* Lock all additions to address
2080 + space. */
2081 +
2082 +/* Flags for `mremap'. */
2083 +#ifdef __USE_GNU
2084 +# define MREMAP_MAYMOVE 1
2085 +# define MREMAP_FIXED 2
2086 +#endif
2087 +
2088 +/* Advise to `madvise'. */
2089 +#ifdef __USE_BSD
2090 +# define MADV_NORMAL 0 /* No further special treatment. */
2091 +# define MADV_RANDOM 1 /* Expect random page references. */
2092 +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
2093 +# define MADV_WILLNEED 3 /* Will need these pages. */
2094 +# define MADV_DONTNEED 4 /* Don't need these pages. */
2095 +# define MADV_REMOVE 9 /* Remove these pages and resources. */
2096 +# define MADV_DONTFORK 10 /* Do not inherit across fork. */
2097 +# define MADV_DOFORK 11 /* Do inherit across fork. */
2098 +#endif
2099 +
2100 +/* The POSIX people had to invent similar names for the same things. */
2101 +#ifdef __USE_XOPEN2K
2102 +# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
2103 +# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
2104 +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
2105 +# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
2106 +# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
2107 +#endif
2108 --- /dev/null
2109 +++ b/libc/sysdeps/linux/avr32/bits/setjmp.h
2110 @@ -0,0 +1,30 @@
2111 +/*
2112 + * Copyright (C) 2004-2005 Atmel Corporation
2113 + *
2114 + * This file is subject to the terms and conditions of the GNU Lesser General
2115 + * Public License. See the file "COPYING.LIB" in the main directory of this
2116 + * archive for more details.
2117 + */
2118 +#ifndef _BITS_SETJMP_H
2119 +#define _BITS_SETJMP_H 1
2120 +
2121 +#if !defined _SETJMP_H && !defined _PTHREAD_H
2122 +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
2123 +#endif
2124 +
2125 +#ifndef _ASM
2126 +/*
2127 + * The jump buffer contains r0-r7, sr, sp and lr. Other registers are
2128 + * not saved.
2129 + */
2130 +typedef int __jmp_buf[11];
2131 +#endif
2132 +
2133 +#define __JMP_BUF_SP 4
2134 +
2135 +/* Test if longjmp to JMPBUF would unwind the frame containing a local
2136 + variable at ADDRESS. */
2137 +#define _JMPBUF_UNWINDS(jmpbuf, address) \
2138 + ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
2139 +
2140 +#endif /* _BITS_SETJMP_H */
2141 --- /dev/null
2142 +++ b/libc/sysdeps/linux/avr32/bits/stackinfo.h
2143 @@ -0,0 +1,28 @@
2144 +/* Copyright (C) 1999 Free Software Foundation, Inc.
2145 + This file is part of the GNU C Library.
2146 +
2147 + The GNU C Library is free software; you can redistribute it and/or
2148 + modify it under the terms of the GNU Lesser General Public
2149 + License as published by the Free Software Foundation; either
2150 + version 2.1 of the License, or (at your option) any later version.
2151 +
2152 + The GNU C Library is distributed in the hope that it will be useful,
2153 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2154 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2155 + Lesser General Public License for more details.
2156 +
2157 + You should have received a copy of the GNU Lesser General Public
2158 + License along with the GNU C Library; if not, write to the Free
2159 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2160 + 02111-1307 USA. */
2161 +
2162 +/* This file contains a bit of information about the stack allocation
2163 + of the processor. */
2164 +
2165 +#ifndef _STACKINFO_H
2166 +#define _STACKINFO_H 1
2167 +
2168 +/* On AVR32 the stack grows down. */
2169 +#define _STACK_GROWS_DOWN 1
2170 +
2171 +#endif /* stackinfo.h */
2172 --- /dev/null
2173 +++ b/libc/sysdeps/linux/avr32/bits/syscalls.h
2174 @@ -0,0 +1,143 @@
2175 +#ifndef _BITS_SYSCALLS_H
2176 +#define _BITS_SYSCALLS_H
2177 +#ifndef _SYSCALL_H
2178 +# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
2179 +#endif
2180 +
2181 +/*
2182 + * This includes the `__NR_<name>' syscall numbers taken from the
2183 + * Linux kernel header files. It also defines the traditional
2184 + * `SYS_<name>' macros for older programs.
2185 + */
2186 +#include <bits/sysnum.h>
2187 +
2188 +#ifndef __ASSEMBLER__
2189 +
2190 +#include <errno.h>
2191 +
2192 +#define SYS_ify(syscall_name) (__NR_##syscall_name)
2193 +
2194 +#undef _syscall0
2195 +#define _syscall0(type,name) \
2196 + type name(void) \
2197 + { \
2198 + return (type)(INLINE_SYSCALL(name, 0)); \
2199 + }
2200 +
2201 +#undef _syscall1
2202 +#define _syscall1(type,name,type1,arg1) \
2203 + type name(type1 arg1) \
2204 + { \
2205 + return (type)(INLINE_SYSCALL(name, 1, arg1)); \
2206 + }
2207 +
2208 +#undef _syscall2
2209 +#define _syscall2(type,name,type1,arg1,type2,arg2) \
2210 + type name(type1 arg1, type2 arg2) \
2211 + { \
2212 + return (type)(INLINE_SYSCALL(name, 2, arg1, arg2)); \
2213 + }
2214 +
2215 +#undef _syscall3
2216 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
2217 + type name(type1 arg1, type2 arg2, type3 arg3) \
2218 + { \
2219 + return (type)(INLINE_SYSCALL(name, 3, arg1, \
2220 + arg2, arg3)); \
2221 + }
2222 +
2223 +#undef _syscall4
2224 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
2225 + type4,arg4) \
2226 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
2227 + { \
2228 + return (type)(INLINE_SYSCALL(name, 4, arg1, arg2, \
2229 + arg3, arg4)); \
2230 + }
2231 +
2232 +#undef _syscall5
2233 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
2234 + type4,arg4,type5,arg5) \
2235 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
2236 + type5 arg5) \
2237 + { \
2238 + return (type)(INLINE_SYSCALL(name, 5, arg1, arg2, \
2239 + arg3, arg4, arg5)); \
2240 + }
2241 +
2242 +#undef _syscall6
2243 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3, \
2244 + type4,arg4,type5,arg5,type6,arg6) \
2245 + type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
2246 + type5 arg5, type6 arg6) \
2247 + { \
2248 + return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
2249 + arg4, arg5, arg6)); \
2250 + }
2251 +
2252 +#undef unlikely
2253 +#define unlikely(x) __builtin_expect((x), 0)
2254 +
2255 +#undef INLINE_SYSCALL
2256 +#define INLINE_SYSCALL(name, nr, args...) \
2257 + ({ \
2258 + unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
2259 + if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
2260 + __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
2261 + _sys_result = (unsigned int) -1; \
2262 + } \
2263 + (int) _sys_result; \
2264 + })
2265 +
2266 +#undef INTERNAL_SYSCALL_DECL
2267 +#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
2268 +
2269 +#undef INTERNAL_SYSCALL
2270 +#define INTERNAL_SYSCALL(name, err, nr, args...) \
2271 + ({ \
2272 + register int _a1 asm ("r12"); \
2273 + register int _scno asm("r8") = SYS_ify(name); \
2274 + LOAD_ARGS_##nr (args); \
2275 + asm volatile ("scall /* syscall " #name " */" \
2276 + : "=r" (_a1) \
2277 + : "r"(_scno) ASM_ARGS_##nr \
2278 + : "cc", "memory"); \
2279 + _a1; \
2280 + })
2281 +
2282 +#undef INTERNAL_SYSCALL_ERROR_P
2283 +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
2284 + ((unsigned int)(val) >= 0xfffff001U)
2285 +
2286 +#undef INTERNAL_SYSCALL_ERRNO
2287 +#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
2288 +
2289 +#define LOAD_ARGS_0() do { } while(0)
2290 +#define ASM_ARGS_0
2291 +#define LOAD_ARGS_1(a1) \
2292 + _a1 = (int) (a1); \
2293 + LOAD_ARGS_0()
2294 +#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1)
2295 +#define LOAD_ARGS_2(a1, a2) \
2296 + register int _a2 asm("r11") = (int)(a2); \
2297 + LOAD_ARGS_1(a1)
2298 +#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2)
2299 +#define LOAD_ARGS_3(a1, a2, a3) \
2300 + register int _a3 asm("r10") = (int)(a3); \
2301 + LOAD_ARGS_2(a1, a2)
2302 +#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3)
2303 +#define LOAD_ARGS_4(a1, a2, a3, a4) \
2304 + register int _a4 asm("r9") = (int)(a4); \
2305 + LOAD_ARGS_3(a1, a2, a3)
2306 +#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4)
2307 +#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
2308 + register int _a5 asm("r5") = (int)(a5); \
2309 + LOAD_ARGS_4(a1, a2, a3, a4)
2310 +#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5)
2311 +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
2312 + register int _a6 asm("r3") = (int)(a6); \
2313 + LOAD_ARGS_5(a1, a2, a3, a4, a5)
2314 +#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6)
2315 +
2316 +#endif /* __ASSEMBLER__ */
2317 +#endif /* _BITS_SYSCALLS_H */
2318 --- /dev/null
2319 +++ b/libc/sysdeps/linux/avr32/bits/uClibc_arch_features.h
2320 @@ -0,0 +1,45 @@
2321 +/*
2322 + * Track misc arch-specific features that aren't config options
2323 + */
2324 +
2325 +#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
2326 +#define _BITS_UCLIBC_ARCH_FEATURES_H
2327 +
2328 +/* instruction used when calling abort() to kill yourself */
2329 +/* trigger illegal instruction exception, same as BUG in Linux */
2330 +#define __UCLIBC_ABORT_INSTRUCTION__ ".short 0x5df0"
2331 +
2332 +/* can your target use syscall6() for mmap ? */
2333 +#define __UCLIBC_MMAP_HAS_6_ARGS__
2334 +
2335 +/* does your target use syscall4() for truncate64 ? (32bit arches only) */
2336 +#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
2337 +
2338 +/* does your target have a broken create_module() ? */
2339 +#undef __UCLIBC_BROKEN_CREATE_MODULE__
2340 +
2341 +/* does your target have to worry about older [gs]etrlimit() ? */
2342 +#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
2343 +
2344 +/* does your target prefix all symbols with an _ ? */
2345 +#define __UCLIBC_NO_UNDERSCORES__
2346 +
2347 +/* does your target have an asm .set ? */
2348 +#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
2349 +
2350 +/* define if target doesn't like .global */
2351 +#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
2352 +
2353 +/* define if target supports .weak */
2354 +#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
2355 +
2356 +/* define if target supports .weakext */
2357 +#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
2358 +
2359 +/* needed probably only for ppc64 */
2360 +#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
2361 +
2362 +/* define if target supports IEEE signed zero floats */
2363 +#define __UCLIBC_HAVE_SIGNED_ZERO__
2364 +
2365 +#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
2366 --- /dev/null
2367 +++ b/libc/sysdeps/linux/avr32/bits/wordsize.h
2368 @@ -0,0 +1 @@
2369 +#define __WORDSIZE 32
2370 --- /dev/null
2371 +++ b/libc/sysdeps/linux/avr32/brk.c
2372 @@ -0,0 +1,31 @@
2373 +/*
2374 + * Copyright (C) 2004-2007 Atmel Corporation
2375 + *
2376 + * This file is subject to the terms and conditions of the GNU Lesser General
2377 + * Public License. See the file "COPYING.LIB" in the main directory of this
2378 + * archive for more details.
2379 + */
2380 +#include <errno.h>
2381 +#include <unistd.h>
2382 +#include <sys/syscall.h>
2383 +
2384 +libc_hidden_proto(brk)
2385 +
2386 +void *__curbrk attribute_hidden = 0;
2387 +
2388 +int brk (void *addr)
2389 +{
2390 + void *newbrk;
2391 +
2392 + newbrk = (void *)INLINE_SYSCALL(brk, 1, addr);
2393 +
2394 + __curbrk = newbrk;
2395 +
2396 + if (newbrk < addr) {
2397 + __set_errno (ENOMEM);
2398 + return -1;
2399 + }
2400 +
2401 + return 0;
2402 +}
2403 +libc_hidden_def(brk)
2404 --- /dev/null
2405 +++ b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
2406 @@ -0,0 +1,16 @@
2407 +/*
2408 + * Copyright (C) 2004-2007 Atmel Corporation
2409 + *
2410 + * This file is subject to the terms and conditions of the GNU Lesser General
2411 + * Public License. See the file "COPYING.LIB" in the main directory of this
2412 + * archive for more details.
2413 + */
2414 +
2415 + /* This just does a tail-call to __sigsetjmp(env, 0) */
2416 + .global _setjmp
2417 + .type _setjmp,"function"
2418 + .align 1
2419 +_setjmp:
2420 + mov r11, 0
2421 + bral __GI___sigsetjmp
2422 + .size _setjmp, . - _setjmp
2423 --- /dev/null
2424 +++ b/libc/sysdeps/linux/avr32/bsd-setjmp.S
2425 @@ -0,0 +1,16 @@
2426 +/*
2427 + * Copyright (C) 2004-2007 Atmel Corporation
2428 + *
2429 + * This file is subject to the terms and conditions of the GNU Lesser General
2430 + * Public License. See the file "COPYING.LIB" in the main directory of this
2431 + * archive for more details.
2432 + */
2433 +
2434 + /* This just does a tail-call to __sigsetjmp(env, 1) */
2435 + .global setjmp
2436 + .type setjmp,"function"
2437 + .align 1
2438 +setjmp:
2439 + mov r11, 1
2440 + bral __GI___sigsetjmp
2441 + .size setjmp, . - setjmp
2442 --- /dev/null
2443 +++ b/libc/sysdeps/linux/avr32/clone.c
2444 @@ -0,0 +1,41 @@
2445 +/*
2446 + * Copyright (C) 2004 Atmel Corporation
2447 + *
2448 + * This file is subject to the terms and conditions of the GNU Lesser General
2449 + * Public License. See the file "COPYING.LIB" in the main directory of this
2450 + * archive for more details.
2451 + */
2452 +#include <errno.h>
2453 +#include <sys/syscall.h>
2454 +#include <unistd.h>
2455 +
2456 +/*
2457 + * I don't know if we can be absolutely certain that the fn and arg
2458 + * parameters are preserved when returning as the child. If the
2459 + * compiler stores them in registers (r0-r7), they should be.
2460 + */
2461 +int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
2462 +{
2463 + register int (*_fn)(void *arg) = fn;
2464 + register void *_arg = arg;
2465 + int err;
2466 +
2467 + /* Sanity check the arguments */
2468 + err = -EINVAL;
2469 + if (!fn)
2470 + goto syscall_error;
2471 + if (!child_stack)
2472 + goto syscall_error;
2473 +
2474 + err = INLINE_SYSCALL(clone, 2, flags, child_stack);
2475 + if (err < 0)
2476 + goto syscall_error;
2477 + else if (err != 0)
2478 + return err;
2479 +
2480 + _exit(_fn(_arg));
2481 +
2482 +syscall_error:
2483 + __set_errno (-err);
2484 + return -1;
2485 +}
2486 --- /dev/null
2487 +++ b/libc/sysdeps/linux/avr32/crt1.S
2488 @@ -0,0 +1,97 @@
2489 +/*
2490 + * Copyright (C) 2004-2007 Atmel Corporation
2491 + *
2492 + * This file is subject to the terms and conditions of the GNU Lesser General
2493 + * Public License. See the file "COPYING.LIB" in the main directory of this
2494 + * archive for more details.
2495 + *
2496 + * When we enter _start, the stack looks like this:
2497 + * argc argument counter
2498 + * argv[0] pointer to program name
2499 + * argv[1..argc-1] pointers to program args
2500 + * NULL
2501 + * env[0..N] pointers to environment variables
2502 + * NULL
2503 + *
2504 + * r12 contains a function pointer to be registered with `atexit'.
2505 + * This is how the dynamic linker arranges to have DT_FINI functions
2506 + * called for shared libraries that have been loaded before this
2507 + * code runs.
2508 + *
2509 + * We're going to call the following function:
2510 + * __uClibc_main(int (*main)(int, char **, char **), int argc,
2511 + * char **argv, void (*app_init)(void), void (*app_fini)(void),
2512 + * void (*rtld_fini)(void), void *stack_end)
2513 + *
2514 + * So we need to set up things as follows:
2515 + * r12 = address of main
2516 + * r11 = argc
2517 + * r10 = &argv[0]
2518 + * r9 = address of _init
2519 + * r8 = address of _fini
2520 + * sp[0] = whatever we got passed in r12
2521 + */
2522 +
2523 +#include <features.h>
2524 +
2525 + .text
2526 + .global _start
2527 + .type _start, @function
2528 +_start:
2529 + /* Clear the frame pointer and link register since this is the outermost frame. */
2530 + mov r7, 0
2531 + mov lr, 0
2532 +
2533 + ld.w r11, sp++ /* argc */
2534 + mov r10, sp /* &argv[0] */
2535 +
2536 + st.w --sp, r10 /* stack_end */
2537 + st.w --sp, r12 /* rtld_fini */
2538 +
2539 +#ifdef __PIC__
2540 + lddpc r6, .L_GOT
2541 +.L_RGOT:
2542 + rsub r6, pc
2543 + lda.w r9, _init
2544 + lda.w r8, _fini
2545 + lda.w r12, main
2546 +
2547 + /* Ok, now run uClibc's main() -- should not return */
2548 + call __uClibc_main
2549 +
2550 + .align 2
2551 +.L_GOT:
2552 + .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
2553 +#else
2554 + lddpc r9, __init_addr /* app_init */
2555 + lddpc r8, __fini_addr /* app_fini */
2556 + lddpc r12, __main_addr /* main */
2557 +
2558 + /* Ok, now run uClibc's main() -- should not return */
2559 + lddpc pc, ___uClibc_main_addr
2560 +
2561 + .align 2
2562 +__init_addr:
2563 + .long _init
2564 +__fini_addr:
2565 + .long _fini
2566 +__main_addr:
2567 + .long main
2568 +___uClibc_main_addr:
2569 + .long __uClibc_main
2570 +#endif
2571 + .size _start, . - _start
2572 +
2573 + /*
2574 + * The LSB says we need this.
2575 + */
2576 + .section ".note.ABI-tag", "a"
2577 + .align 4
2578 + .long 2f - 1f /* namesz */
2579 + .long 4f - 3f /* descsz */
2580 + .long 1 /* type */
2581 +1: .asciz "GNU" /* name */
2582 +2: .align 4
2583 +3: .long 0 /* Linux executable */
2584 + .long 2,6,0 /* Earliest compatible kernel */
2585 +4: .align 4
2586 --- /dev/null
2587 +++ b/libc/sysdeps/linux/avr32/crti.S
2588 @@ -0,0 +1,26 @@
2589 +
2590 + .section .init
2591 + .align 2
2592 + .global _init
2593 + .type _init, @function
2594 +_init:
2595 + stm --sp, r6, lr
2596 + lddpc r6, 2f
2597 +1: rsub r6, pc
2598 + rjmp 3f
2599 + .align 2
2600 +2: .long 1b - _GLOBAL_OFFSET_TABLE_
2601 +3:
2602 +
2603 + .section .fini
2604 + .align 2
2605 + .global _fini
2606 + .type _fini, @function
2607 +_fini:
2608 + stm --sp, r6, lr
2609 + lddpc r6, 2f
2610 +1: rsub r6, pc
2611 + rjmp 3f
2612 + .align 2
2613 +2: .long 1b - _GLOBAL_OFFSET_TABLE_
2614 +3:
2615 --- /dev/null
2616 +++ b/libc/sysdeps/linux/avr32/crtn.S
2617 @@ -0,0 +1,14 @@
2618 +
2619 + .section .init
2620 + .align 2
2621 + .global _init
2622 + .type _init, @function
2623 + ldm sp++, r6, pc
2624 + .size _init, . - _init
2625 +
2626 + .section .fini
2627 + .align 2
2628 + .global _fini
2629 + .type _fini, @function
2630 + ldm sp++, r6, pc
2631 + .size _fini, . - _fini
2632 --- /dev/null
2633 +++ b/libc/sysdeps/linux/avr32/mmap.c
2634 @@ -0,0 +1,33 @@
2635 +/*
2636 + * Copyright (C) 2004-2007 Atmel Corporation
2637 + *
2638 + * This file is subject to the terms and conditions of the GNU Lesser General
2639 + * Public License. See the file "COPYING.LIB" in the main directory of this
2640 + * archive for more details.
2641 + */
2642 +
2643 +#include <errno.h>
2644 +#include <unistd.h>
2645 +#include <sys/mman.h>
2646 +#include <sys/syscall.h>
2647 +
2648 +libc_hidden_proto(mmap)
2649 +
2650 +static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot,
2651 + int, flags, int, fd, __off_t, pgoff);
2652 +
2653 +__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
2654 +{
2655 + unsigned long page_size = sysconf(_SC_PAGESIZE);
2656 + unsigned long pgoff;
2657 +
2658 + if (offset & (page_size - 1)) {
2659 + __set_errno(EINVAL);
2660 + return MAP_FAILED;
2661 + }
2662 +
2663 + pgoff = (unsigned long)offset >> (31 - __builtin_clz(page_size));
2664 +
2665 + return mmap2(addr, len, prot, flags, fd, pgoff);
2666 +}
2667 +libc_hidden_def(mmap)
2668 --- /dev/null
2669 +++ b/libc/sysdeps/linux/avr32/setjmp.S
2670 @@ -0,0 +1,29 @@
2671 +/*
2672 + * Copyright (C) 2004-2007 Atmel Corporation
2673 + *
2674 + * This file is subject to the terms and conditions of the GNU Lesser General
2675 + * Public License. See the file "COPYING.LIB" in the main directory of this
2676 + * archive for more details.
2677 + */
2678 +#define _SETJMP_H
2679 +#define _ASM
2680 +#include <bits/setjmp.h>
2681 +
2682 + .text
2683 +
2684 + .global __sigsetjmp
2685 + .type __sigsetjmp,"function"
2686 +
2687 + .align 1
2688 +__sigsetjmp:
2689 + mustr r8
2690 + stm r12, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
2691 +
2692 + /*
2693 + * Make a tail call to __sigjmp_save; it takes the same args
2694 + * and is hidden so we don't need to mess around with the GOT.
2695 + */
2696 + rjmp __sigjmp_save
2697 + .size __sigsetjmp, . - __sigsetjmp
2698 +
2699 +libc_hidden_def(__sigsetjmp)
2700 --- /dev/null
2701 +++ b/libc/sysdeps/linux/avr32/sigaction.c
2702 @@ -0,0 +1,59 @@
2703 +/*
2704 + * Copyright (C) 2004-2007 Atmel Corporation
2705 + *
2706 + * This file is subject to the terms and conditions of the GNU Lesser General
2707 + * Public License. See the file "COPYING.LIB" in the main directory of this
2708 + * archive for more details.
2709 + */
2710 +#include <errno.h>
2711 +#include <signal.h>
2712 +#include <string.h>
2713 +#include <sys/syscall.h>
2714 +#include <bits/kernel_sigaction.h>
2715 +
2716 +#define SA_RESTORER 0x04000000
2717 +extern void __default_rt_sa_restorer(void);
2718 +
2719 +libc_hidden_proto(memcpy)
2720 +
2721 +/*
2722 + * If act is not NULL, change the action for sig to *act.
2723 + * If oact is not NULL, put the old action for sig in *oact.
2724 + */
2725 +int __libc_sigaction(int signum, const struct sigaction *act,
2726 + struct sigaction *oldact)
2727 +{
2728 + struct kernel_sigaction kact, koact;
2729 + int result;
2730 +
2731 + if (act) {
2732 + kact.k_sa_handler = act->sa_handler;
2733 + memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
2734 + kact.sa_flags = act->sa_flags;
2735 + if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
2736 + kact.sa_restorer = act->sa_restorer;
2737 + else
2738 + kact.sa_restorer = __default_rt_sa_restorer;
2739 + kact.sa_flags |= SA_RESTORER;
2740 + }
2741 +
2742 + result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
2743 + oldact ? __ptrvalue(&koact) : NULL,
2744 + _NSIG / 8);
2745 +
2746 + if (oldact && result >= 0) {
2747 + oldact->sa_handler = koact.k_sa_handler;
2748 + memcpy(&oldact->sa_mask, &koact.sa_mask,
2749 + sizeof(oldact->sa_mask));
2750 + oldact->sa_flags = koact.sa_flags;
2751 + oldact->sa_restorer = koact.sa_restorer;
2752 + }
2753 +
2754 + return result;
2755 +}
2756 +
2757 +#ifndef LIBC_SIGACTION
2758 +libc_hidden_proto(sigaction)
2759 +weak_alias(__libc_sigaction, sigaction)
2760 +libc_hidden_weak(sigaction)
2761 +#endif
2762 --- /dev/null
2763 +++ b/libc/sysdeps/linux/avr32/sigrestorer.S
2764 @@ -0,0 +1,15 @@
2765 +/*
2766 + * Copyright (C) 2004 Atmel Corporation
2767 + *
2768 + * This file is subject to the terms and conditions of the GNU Lesser General
2769 + * Public License. See the file "COPYING.LIB" in the main directory of this
2770 + * archive for more details.
2771 + */
2772 +#include <sys/syscall.h>
2773 +
2774 + .global __default_rt_sa_restorer
2775 + .type __default_rt_sa_restorer,"function"
2776 + .align 1
2777 +__default_rt_sa_restorer:
2778 + mov r8, __NR_rt_sigreturn
2779 + scall
2780 --- /dev/null
2781 +++ b/libc/sysdeps/linux/avr32/sys/elf.h
2782 @@ -0,0 +1,26 @@
2783 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
2784 + This file is part of the GNU C Library.
2785 +
2786 + The GNU C Library is free software; you can redistribute it and/or
2787 + modify it under the terms of the GNU Lesser General Public
2788 + License as published by the Free Software Foundation; either
2789 + version 2.1 of the License, or (at your option) any later version.
2790 +
2791 + The GNU C Library is distributed in the hope that it will be useful,
2792 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2793 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2794 + Lesser General Public License for more details.
2795 +
2796 + You should have received a copy of the GNU Lesser General Public
2797 + License along with the GNU C Library; if not, write to the Free
2798 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2799 + 02111-1307 USA. */
2800 +
2801 +#ifndef _SYS_ELF_H
2802 +#define _SYS_ELF_H 1
2803 +
2804 +#warning "This header is obsolete; use <sys/procfs.h> instead."
2805 +
2806 +#include <sys/procfs.h>
2807 +
2808 +#endif /* sys/elf.h */
2809 --- /dev/null
2810 +++ b/libc/sysdeps/linux/avr32/sys/procfs.h
2811 @@ -0,0 +1,123 @@
2812 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
2813 + This file is part of the GNU C Library.
2814 +
2815 + The GNU C Library is free software; you can redistribute it and/or
2816 + modify it under the terms of the GNU Lesser General Public
2817 + License as published by the Free Software Foundation; either
2818 + version 2.1 of the License, or (at your option) any later version.
2819 +
2820 + The GNU C Library is distributed in the hope that it will be useful,
2821 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2822 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2823 + Lesser General Public License for more details.
2824 +
2825 + You should have received a copy of the GNU Lesser General Public
2826 + License along with the GNU C Library; if not, write to the Free
2827 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2828 + 02111-1307 USA. */
2829 +
2830 +#ifndef _SYS_PROCFS_H
2831 +#define _SYS_PROCFS_H 1
2832 +
2833 +/* This is somewhat modelled after the file of the same name on SVR4
2834 + systems. It provides a definition of the core file format for ELF
2835 + used on Linux. It doesn't have anything to do with the /proc file
2836 + system, even though Linux has one.
2837 +
2838 + Anyway, the whole purpose of this file is for GDB and GDB only.
2839 + Don't read too much into it. Don't use it for anything other than
2840 + GDB unless you know what you are doing. */
2841 +
2842 +#include <features.h>
2843 +#include <sys/time.h>
2844 +#include <sys/types.h>
2845 +#include <sys/user.h>
2846 +
2847 +__BEGIN_DECLS
2848 +
2849 +/* Type for a general-purpose register. */
2850 +typedef unsigned long elf_greg_t;
2851 +
2852 +/* And the whole bunch of them. We could have used `struct
2853 + user_regs' directly in the typedef, but tradition says that
2854 + the register set is an array, which does have some peculiar
2855 + semantics, so leave it that way. */
2856 +#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
2857 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
2858 +
2859 +/* Register set for the floating-point registers. */
2860 +typedef struct user_fpregs elf_fpregset_t;
2861 +
2862 +/* Signal info. */
2863 +struct elf_siginfo
2864 + {
2865 + int si_signo; /* Signal number. */
2866 + int si_code; /* Extra code. */
2867 + int si_errno; /* Errno. */
2868 + };
2869 +
2870 +/* Definitions to generate Intel SVR4-like core files. These mostly
2871 + have the same names as the SVR4 types with "elf_" tacked on the
2872 + front to prevent clashes with Linux definitions, and the typedef
2873 + forms have been avoided. This is mostly like the SVR4 structure,
2874 + but more Linuxy, with things that Linux does not support and which
2875 + GDB doesn't really use excluded. */
2876 +
2877 +struct elf_prstatus
2878 + {
2879 + struct elf_siginfo pr_info; /* Info associated with signal. */
2880 + short int pr_cursig; /* Current signal. */
2881 + unsigned long int pr_sigpend; /* Set of pending signals. */
2882 + unsigned long int pr_sighold; /* Set of held signals. */
2883 + __pid_t pr_pid;
2884 + __pid_t pr_ppid;
2885 + __pid_t pr_pgrp;
2886 + __pid_t pr_sid;
2887 + struct timeval pr_utime; /* User time. */
2888 + struct timeval pr_stime; /* System time. */
2889 + struct timeval pr_cutime; /* Cumulative user time. */
2890 + struct timeval pr_cstime; /* Cumulative system time. */
2891 + elf_gregset_t pr_reg; /* GP registers. */
2892 + int pr_fpvalid; /* True if math copro being used. */
2893 + };
2894 +
2895 +
2896 +#define ELF_PRARGSZ (80) /* Number of chars for args. */
2897 +
2898 +struct elf_prpsinfo
2899 + {
2900 + char pr_state; /* Numeric process state. */
2901 + char pr_sname; /* Char for pr_state. */
2902 + char pr_zomb; /* Zombie. */
2903 + char pr_nice; /* Nice val. */
2904 + unsigned long int pr_flag; /* Flags. */
2905 + unsigned short int pr_uid;
2906 + unsigned short int pr_gid;
2907 + int pr_pid, pr_ppid, pr_pgrp, pr_sid;
2908 + /* Lots missing */
2909 + char pr_fname[16]; /* Filename of executable. */
2910 + char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
2911 + };
2912 +
2913 +/* The rest of this file provides the types for emulation of the
2914 + Solaris <proc_service.h> interfaces that should be implemented by
2915 + users of libthread_db. */
2916 +
2917 +/* Addresses. */
2918 +typedef void *psaddr_t;
2919 +
2920 +/* Register sets. Linux has different names. */
2921 +typedef elf_gregset_t prgregset_t;
2922 +typedef elf_fpregset_t prfpregset_t;
2923 +
2924 +/* We don't have any differences between processes and threads,
2925 + therefore have only one PID type. */
2926 +typedef __pid_t lwpid_t;
2927 +
2928 +/* Process status and info. In the end we do provide typedefs for them. */
2929 +typedef struct elf_prstatus prstatus_t;
2930 +typedef struct elf_prpsinfo prpsinfo_t;
2931 +
2932 +__END_DECLS
2933 +
2934 +#endif /* sys/procfs.h */
2935 --- /dev/null
2936 +++ b/libc/sysdeps/linux/avr32/sys/ucontext.h
2937 @@ -0,0 +1,90 @@
2938 +/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
2939 + This file is part of the GNU C Library.
2940 +
2941 + The GNU C Library is free software; you can redistribute it and/or
2942 + modify it under the terms of the GNU Lesser General Public
2943 + License as published by the Free Software Foundation; either
2944 + version 2.1 of the License, or (at your option) any later version.
2945 +
2946 + The GNU C Library is distributed in the hope that it will be useful,
2947 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2948 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2949 + Lesser General Public License for more details.
2950 +
2951 + You should have received a copy of the GNU Lesser General Public
2952 + License along with the GNU C Library; if not, write to the Free
2953 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2954 + 02111-1307 USA. */
2955 +
2956 +/* Linux/AVR32 ABI compliant context switching support. */
2957 +
2958 +#ifndef _SYS_UCONTEXT_H
2959 +#define _SYS_UCONTEXT_H 1
2960 +
2961 +#include <features.h>
2962 +#include <signal.h>
2963 +#include <sys/procfs.h>
2964 +#include <bits/sigcontext.h>
2965 +
2966 +typedef int greg_t;
2967 +
2968 +/* Number of general registers. */
2969 +#define NGREG 16
2970 +
2971 +/* Container for all general registers. */
2972 +typedef elf_gregset_t gregset_t;
2973 +
2974 +/* Number of each register is the `gregset_t' array. */
2975 +enum
2976 +{
2977 + R0 = 0,
2978 +#define R0 R0
2979 + R1 = 1,
2980 +#define R1 R1
2981 + R2 = 2,
2982 +#define R2 R2
2983 + R3 = 3,
2984 +#define R3 R3
2985 + R4 = 4,
2986 +#define R4 R4
2987 + R5 = 5,
2988 +#define R5 R5
2989 + R6 = 6,
2990 +#define R6 R6
2991 + R7 = 7,
2992 +#define R7 R7
2993 + R8 = 8,
2994 +#define R8 R8
2995 + R9 = 9,
2996 +#define R9 R9
2997 + R10 = 10,
2998 +#define R10 R10
2999 + R11 = 11,
3000 +#define R11 R11
3001 + R12 = 12,
3002 +#define R12 R12
3003 + R13 = 13,
3004 +#define R13 R13
3005 + R14 = 14,
3006 +#define R14 R14
3007 + R15 = 15
3008 +#define R15 R15
3009 +};
3010 +
3011 +/* Structure to describe FPU registers. */
3012 +typedef elf_fpregset_t fpregset_t;
3013 +
3014 +/* Context to describe whole processor state. */
3015 +typedef struct sigcontext mcontext_t;
3016 +
3017 +/* Userlevel context. */
3018 +typedef struct ucontext
3019 +{
3020 + unsigned long uc_flags;
3021 + struct ucontext *uc_link;
3022 + stack_t uc_stack;
3023 + mcontext_t uc_mcontext;
3024 + sigset_t uc_sigmask; /* mask last for extensibility */
3025 +} ucontext_t;
3026 +
3027 +#endif /* sys/ucontext.h */
3028 --- /dev/null
3029 +++ b/libc/sysdeps/linux/avr32/sys/user.h
3030 @@ -0,0 +1,46 @@
3031 +#ifndef _SYS_USER_H
3032 +#define _SYS_USER_H
3033 +
3034 +struct user_fpregs
3035 +{
3036 +
3037 +};
3038 +
3039 +struct user_regs
3040 +{
3041 + unsigned long sr;
3042 + unsigned long pc;
3043 + unsigned long lr;
3044 + unsigned long sp;
3045 + unsigned long r12;
3046 + unsigned long r11;
3047 + unsigned long r10;
3048 + unsigned long r9;
3049 + unsigned long r8;
3050 + unsigned long r7;
3051 + unsigned long r6;
3052 + unsigned long r5;
3053 + unsigned long r4;
3054 + unsigned long r3;
3055 + unsigned long r2;
3056 + unsigned long r1;
3057 + unsigned long r0;
3058 + unsigned long r12_orig;
3059 +};
3060 +
3061 +struct user
3062 +{
3063 + struct user_regs regs; /* general registers */
3064 + size_t u_tsize; /* text size (pages) */
3065 + size_t u_dsize; /* data size (pages) */
3066 + size_t u_ssize; /* stack size (pages) */
3067 + unsigned long start_code; /* text starting address */
3068 + unsigned long start_data; /* data starting address */
3069 + unsigned long start_stack; /* stack starting address */
3070 + long int signal; /* signal causing core dump */
3071 + struct user_regs * u_ar0; /* help gdb find registers */
3072 + unsigned long magic; /* identifies a core file */
3073 + char u_comm[32]; /* user command name */
3074 +};
3075 +
3076 +#endif /* _SYS_USER_H */
3077 --- /dev/null
3078 +++ b/libc/sysdeps/linux/avr32/syscall.S
3079 @@ -0,0 +1,71 @@
3080 +/*
3081 + * Copyright (C) 2004-2007 Atmel Corporation
3082 + *
3083 + * This file is subject to the terms and conditions of the GNU Lesser General
3084 + * Public License. See the file "COPYING.LIB" in the main directory of this
3085 + * archive for more details.
3086 + */
3087 +#include <features.h>
3088 +
3089 + .text
3090 +
3091 + /*
3092 + * long int syscall(long int sysno, ...)
3093 + */
3094 + .global syscall
3095 + .type syscall, @function
3096 + .align 2
3097 +syscall:
3098 + stm --sp, r3,r5,r6,lr
3099 + sub lr, sp, -16
3100 + mov r8, r12
3101 + ldm lr, r3,r5,r9-r12
3102 + scall
3103 + cp.w r12, -4095
3104 + brlo .Ldone
3105 +
3106 +#ifdef __PIC__
3107 + lddpc r6, .Lgot
3108 +.Lgotcalc:
3109 + rsub r6, pc
3110 +# ifdef __UCLIBC_HAS_THREADS__
3111 + rsub r3, r12, 0
3112 + mcall r6[__errno_location@got]
3113 + st.w r12[0], r3
3114 +# else
3115 + ld.w r3, r6[errno@got]
3116 + neg r12
3117 + st.w r3[0], r12
3118 +# endif
3119 +#else
3120 +# ifdef __UCLIBC_HAS_THREADS__
3121 + rsub r3, r12, 0
3122 + mcall .Lerrno_location
3123 + st.w r12[0], r3
3124 +# else
3125 + lddpc r3, .Lerrno
3126 + neg r12
3127 + st.w r3[0], r12
3128 +# endif
3129 +#endif
3130 + mov r12, -1
3131 +
3132 +.Ldone:
3133 + ldm sp++, r3,r5,r6,pc
3134 +
3135 + .align 2
3136 +#ifdef __PIC__
3137 +.Lgot:
3138 + .long .Lgotcalc - _GLOBAL_OFFSET_TABLE_
3139 +#else
3140 +# ifdef __UCLIBC_HAS_THREADS__
3141 +.Lerrno_location:
3142 + .long __errno_location
3143 +# else
3144 +.Lerrno:
3145 + .long errno
3146 +# endif
3147 +#endif
3148 +
3149 +
3150 + .size syscall, . - syscall
3151 --- /dev/null
3152 +++ b/libc/sysdeps/linux/avr32/vfork.S
3153 @@ -0,0 +1,58 @@
3154 +/*
3155 + * Copyright (C) 2005 Atmel Corporation
3156 + *
3157 + * This file is subject to the terms and conditions of the GNU Lesser General
3158 + * Public License. See the file "COPYING.LIB" in the main directory of this
3159 + * archive for more details.
3160 + */
3161 +
3162 +/*
3163 + * Clone the process without copying the address space. The
3164 + * calling process is suspended until the child either exits
3165 + * or calls execve.
3166 + *
3167 + * This all means that we cannot rely on the stack to store
3168 + * away registers, since they will be overwritten by the child
3169 + * as soon as it makes another function call (e.g. execve()).
3170 + * Fortunately, the Linux kernel preserves LR across system calls.
3171 + */
3172 +
3173 +#include <features.h>
3174 +#include <sys/syscall.h>
3175 +
3176 + .global __vfork
3177 + .type __vfork,@function
3178 + .align 1
3179 +__vfork:
3180 + mov r8, __NR_vfork
3181 + scall
3182 + cp.w r12, -4096
3183 + retls r12
3184 +
3185 + /* vfork failed, so we may use the stack freely */
3186 + pushm r4-r7,lr
3187 +#ifdef __PIC__
3188 + lddpc r6, .L_GOT
3189 + rsub r4, r12, 0
3190 +.L_RGOT:
3191 + rsub r6, pc
3192 + mcall r6[__errno_location@got]
3193 +#else
3194 + rsub r4, r12, 0
3195 + mcall .L__errno_location
3196 +#endif
3197 + st.w r12[0], r4
3198 + popm r4-r7,pc,r12=-1
3199 +
3200 + .align 2
3201 +#ifdef __PIC__
3202 +.L_GOT:
3203 + .long .L_RGOT - _GLOBAL_OFFSET_TABLE_
3204 +#else
3205 +.L__errno_location:
3206 + .long __errno_location
3207 +#endif
3208 + .size __vfork, . - __vfork
3209 +
3210 +weak_alias(__vfork,vfork)
3211 +libc_hidden_weak(vfork)
3212 --- /dev/null
3213 +++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
3214 @@ -0,0 +1,73 @@
3215 +/* Machine-dependent pthreads configuration and inline functions.
3216 + *
3217 + * Copyright (C) 2005-2007 Atmel Corporation
3218 + *
3219 + * This file is subject to the terms and conditions of the GNU Lesser General
3220 + * Public License. See the file "COPYING.LIB" in the main directory of this
3221 + * archive for more details.
3222 + */
3223 +#ifndef _PT_MACHINE_H
3224 +#define _PT_MACHINE_H 1
3225 +
3226 +#include <features.h>
3227 +
3228 +static inline int
3229 +_test_and_set (int *p, int v)
3230 +{
3231 + int result;
3232 +
3233 + __asm__ __volatile__(
3234 + "/* Inline test and set */\n"
3235 + " xchg %[old], %[mem], %[new]"
3236 + : [old] "=&r"(result)
3237 + : [mem] "r"(p), [new] "r"(v)
3238 + : "memory");
3239 +
3240 + return result;
3241 +}
3242 +
3243 +#ifndef PT_EI
3244 +# define PT_EI extern inline
3245 +#endif
3246 +
3247 +extern long int testandset (int *spinlock);
3248 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
3249 +
3250 +/* Spinlock implementation; required. */
3251 +PT_EI long int
3252 +testandset (int *spinlock)
3253 +{
3254 + return _test_and_set(spinlock, 1);
3255 +}
3256 +
3257 +
3258 +/* Get some notion of the current stack. Need not be exactly the top
3259 + of the stack, just something somewhere in the current frame. */
3260 +#define CURRENT_STACK_FRAME stack_pointer
3261 +register char * stack_pointer __asm__ ("sp");
3262 +
3263 +/* Compare-and-swap for semaphores. */
3264 +
3265 +#define HAS_COMPARE_AND_SWAP
3266 +PT_EI int
3267 +__compare_and_swap(long int *p, long int oldval, long int newval)
3268 +{
3269 + long int result;
3270 +
3271 + __asm__ __volatile__(
3272 + "/* Inline compare and swap */\n"
3273 + "1: ssrf 5\n"
3274 + " ld.w %[result], %[mem]\n"
3275 + " eor %[result], %[old]\n"
3276 + " brne 2f\n"
3277 + " stcond %[mem], %[new]\n"
3278 + " brne 1b\n"
3279 + "2:"
3280 + : [result] "=&r"(result), [mem] "=m"(*p)
3281 + : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
3282 + : "cc", "memory");
3283 +
3284 + return result == 0;
3285 +}
3286 +
3287 +#endif /* pt-machine.h */
3288 --- /dev/null
3289 +++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
3290 @@ -0,0 +1,73 @@
3291 +/* Machine-dependent pthreads configuration and inline functions.
3292 + *
3293 + * Copyright (C) 2005-2007 Atmel Corporation
3294 + *
3295 + * This file is subject to the terms and conditions of the GNU Lesser General
3296 + * Public License. See the file "COPYING.LIB" in the main directory of this
3297 + * archive for more details.
3298 + */
3299 +#ifndef _PT_MACHINE_H
3300 +#define _PT_MACHINE_H 1
3301 +
3302 +#include <features.h>
3303 +
3304 +static inline int
3305 +_test_and_set (int *p, int v) __THROW
3306 +{
3307 + int result;
3308 +
3309 + __asm__ __volatile__(
3310 + "/* Inline test and set */\n"
3311 + " xchg %[old], %[mem], %[new]"
3312 + : [old] "=&r"(result)
3313 + : [mem] "r"(p), [new] "r"(v)
3314 + : "memory");
3315 +
3316 + return result;
3317 +}
3318 +
3319 +#ifndef PT_EI
3320 +# define PT_EI extern inline
3321 +#endif
3322 +
3323 +extern long int testandset (int *spinlock);
3324 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
3325 +
3326 +/* Spinlock implementation; required. */
3327 +PT_EI long int
3328 +testandset (int *spinlock)
3329 +{
3330 + return _test_and_set(spinlock, 1);
3331 +}
3332 +
3333 +
3334 +/* Get some notion of the current stack. Need not be exactly the top
3335 + of the stack, just something somewhere in the current frame. */
3336 +#define CURRENT_STACK_FRAME stack_pointer
3337 +register char * stack_pointer __asm__ ("sp");
3338 +
3339 +/* Compare-and-swap for semaphores. */
3340 +
3341 +#define HAS_COMPARE_AND_SWAP
3342 +PT_EI int
3343 +__compare_and_swap(long int *p, long int oldval, long int newval)
3344 +{
3345 + int result;
3346 +
3347 + __asm__ __volatile__(
3348 + "/* Inline compare and swap */\n"
3349 + "1: ssrf 5\n"
3350 + " ld.w %[result], %[mem]\n"
3351 + " eor %[result], %[old]\n"
3352 + " brne 2f\n"
3353 + " stcond %[mem], %[new]\n"
3354 + " brne 1b\n"
3355 + "2:"
3356 + : [result] "=&r"(result), [mem] "=m"(*p)
3357 + : "m"(*p), [new] "r"(newval), [old] "r"(oldval)
3358 + : "cc", "memory");
3359 +
3360 + return result == 0;
3361 +}
3362 +
3363 +#endif /* pt-machine.h */
3364 --- a/utils/ldd.c
3365 +++ b/utils/ldd.c
3366 @@ -44,6 +44,11 @@
3367 #define ELFCLASSM ELFCLASS32
3368 #endif
3369
3370 +#if defined(__avr32__)
3371 +#define MATCH_MACHINE(x) (x == EM_AVR32)
3372 +#define ELFCLASSM ELFCLASS32
3373 +#endif
3374 +
3375 #if defined(__s390__)
3376 #define MATCH_MACHINE(x) (x == EM_S390)
3377 #define ELFCLASSM ELFCLASS32
This page took 0.205312 seconds and 5 git commands to generate.