+++ /dev/null
-# -*- makefile -*-
-
-$(LINES): $(PROG_LINES) $(KERNEL)
- $(COMP_MESSAGE)
- $(VERBOSE)./$< $(KERNEL) > $@.new || true
- $(VERBOSE)mv $@.new $@
- $(VERBOSE)chmod 644 $@
- $(call INSTALLFILE_RULE,$@,fiasco_lines)
-
-$(PROG_LINES): genlines.c
- $(LINK_MESSAGE)
- $(VERBOSE)$(HOST_CC) -O2 -Wall $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) -o $@ $^
-
-clean-LINES:
- rm -f $(LINES) $(PROG_LINES)
+++ /dev/null
-INTERFACE:
-
-// On ARM the MMIO for the uart is accessible before the MMU is fully up
-EXTENSION class Kernel_uart { enum { Bsp_init_mode = Init_before_mmu }; };
-
-IMPLEMENTATION [arm && kirkwood && serial]:
-
-#include "mem_layout.h"
-#include "kmem.h"
-
-IMPLEMENT
-bool Kernel_uart::startup(unsigned port, int /*irq*/)
-{
- return Uart::startup(Kmem::mmio_remap(Mem_layout::Uart_phys_base), 33);
-}
+++ /dev/null
-INTERFACE [16550 && kirkwood]:
-
-EXTENSION class Uart
-{
-public:
- enum {
- Base_rate = 200000000 / 16,
- Base_ier_bits = 1 << 6,
-
- Access_shift = 2,
- };
-};
-
-IMPLEMENTATION [16550 && kirkwood]:
-
-IMPLEMENT inline NEEDS[Uart::mcr, Uart::ier]
-void Uart::enable_rcv_irq()
-{
- ier(ier() | 1);
-}
+++ /dev/null
-INTERFACE:
-
-// On ARM the MMIO for the uart is accessible before the MMU is fully up
-EXTENSION class Kernel_uart { enum { Bsp_init_mode = Init_before_mmu }; };
-
-IMPLEMENTATION [arm && pxa && serial]:
-
-#include "kmem.h"
-#include "mem_layout.h"
-
-IMPLEMENT
-bool Kernel_uart::startup(unsigned port, int /*irq*/)
-{
- return Uart::startup(Kmem::mmio_remap(Mem_layout::Uart_phys_base), 22);
-}
+++ /dev/null
-INTERFACE [16550 && pxa]:
-
-EXTENSION class Uart
-{
-public:
- enum {
- Base_rate = 921600,
- Base_ier_bits = 1 << 6,
-
- Access_shift = 2,
- };
-};
-
-IMPLEMENTATION [16550 && pxa]:
-
-IMPLEMENT inline NEEDS[Uart::mcr, Uart::ier]
-void Uart::enable_rcv_irq()
-{
- //mcr(mcr() & ~0x08); //XScale DOC is WRONG
- mcr(mcr() | 0x08);
- ier(ier() | 1);
-}
+++ /dev/null
-INTERFACE:
-
-// On ARM the MMIO for the uart is accessible before the MMU is fully up
-EXTENSION class Kernel_uart { enum { Bsp_init_mode = Init_before_mmu }; };
-
-IMPLEMENTATION [arm && tegra2 && serial]:
-
-#include "kmem.h"
-
-IMPLEMENT
-bool Kernel_uart::startup(unsigned, int)
-{
- return Uart::startup(Kmem::mmio_remap(Mem_layout::Uart_phys_base) + 0x300 /* UARTD */, 122);
-}
-
-IMPLEMENTATION [arm && tegra3 && serial]:
-
-#include "kmem.h"
-
-IMPLEMENT
-bool Kernel_uart::startup(unsigned, int)
-{
- if (0)
- return Uart::startup(Kmem::mmio_remap(Mem_layout::Uart_phys_base), 68); // uarta
- return Uart::startup(Kmem::mmio_remap(Mem_layout::Uart_phys_base) + 0x200, 78); // uartc
-}
+++ /dev/null
-INTERFACE [16550 && tegra2]:
-
-EXTENSION class Uart
-{
-public:
- enum {
- Base_rate = 13478400,
- Base_ier_bits = 1 << 6,
-
- Access_shift = 2,
- };
-};
-
-INTERFACE [16550 && tegra3]:
-
-EXTENSION class Uart
-{
-public:
- enum {
- Base_rate = 25459200,
- Base_ier_bits = 1 << 6,
-
- Access_shift = 2,
- };
-};
-
-
-IMPLEMENTATION [16550 && tegra]:
-
-IMPLEMENT inline NEEDS[Uart::mcr, Uart::ier]
-void Uart::enable_rcv_irq()
-{
- ier(ier() | 1);
-}
+++ /dev/null
-#pragma once
-
-#ifdef NDEBUG
-
-# define BUG_ON(expr, ...)
-
-#else
-
-# define BUG_ON(expr, ...) \
-if (EXPECT_FALSE(!!(expr))) \
- { \
- printf("%s:%d: BUG (%s): ", __FILE__, __LINE__, #expr); \
- printf(__VA_ARGS__); kdb_ke("bug"); \
- }
-
-#endif
-
+++ /dev/null
-
-/* Extract debug lines info from an ELF binary stab section */
-
-/*
- * Adam: Note, this file works on 32-bit files only.
- */
-
-#include <stdio.h>
-#include <elf.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#define PAGESIZE 4096
-#define MAX_PAGES 512
-#define LIN_PER_PAGE (PAGESIZE/sizeof(Stab_entry))
-
-typedef struct
-{
- unsigned int n_strx; /* index into string table of name */
- unsigned char n_type; /* type of symbol */
- unsigned char n_other; /* misc info (usually empty) */
- unsigned short n_desc; /* description field */
- unsigned int n_value; /* value of symbol */
-} __attribute__ ((packed)) Stab_entry;
-
-typedef struct
-{
- unsigned int addr;
- unsigned short line;
-} __attribute__ ((packed)) Stab_line;
-
-const unsigned str_max = MAX_PAGES*PAGESIZE;
-const unsigned lin_max = MAX_PAGES*PAGESIZE/sizeof(Stab_line);
-
-static char *str_field;
-static Stab_line *lin_field;
-static unsigned str_end;
-static unsigned lin_end;
-static unsigned func_offset;
-static int have_func;
-
-static Elf32_Shdr*
-elf_sh_lookup(unsigned char *elf_image, int n)
-{
- Elf32_Ehdr *ehdr = (Elf32_Ehdr*)elf_image;
-
- return (n < ehdr->e_shnum)
- ? (Elf32_Shdr*)(elf_image + ehdr->e_shoff + n*ehdr->e_shentsize)
- : 0;
-}
-
-static int
-search_str(const char *str, unsigned len, unsigned *idx)
-{
- const char *c_next, *c, *d;
-
- if (!str_field || !*str_field)
- return 0;
-
- for (c_next=str_field; ; )
- {
- // goto end of string
- for (; *c_next; c_next++)
- ;
-
- // compare strings
- for (c=c_next, d=str+len; d>=str && (*c == *d); c--, d--)
- ;
-
- if (d<str)
- {
- *idx = c+1-str_field;
- // found (could be a substring)
- return 1;
- }
-
- // test for end-of-field
- if (!*++c_next)
- // end of field -- not found
- return 0;
- }
-}
-
-static int
-add_str(const char *str, unsigned len, unsigned *idx)
-{
- // if still included, don't include anymore
- if (search_str(str, len, idx))
- return 1;
-
- // check if str_field is big enough
- if (str_end+len+1 >= str_max)
- {
- fprintf(stderr, "Not enough memory for debug lines (str space)\n");
- return 0;
- }
-
- *idx = str_end;
-
- // add string to end of str_field
- strcpy(str_field+str_end, str);
- str_end += len+1;
-
- // terminate string field
- str_field[str_end] = '\0';
-
- return 1;
-}
-
-// see documentation in "info stabs"
-static int
-add_entry(const Stab_entry *se, const char *se_str)
-{
- const char *se_name = se_str + se->n_strx;
- int se_name_len = strlen(se_name);
- unsigned se_name_idx = 0;
-
- if (se_name_len
- && ((se->n_type == 0x64) || (se->n_type == 0x84)))
- {
- if (!add_str(se_name, se_name_len, &se_name_idx))
- return 0;
- }
-
- if (lin_end >= lin_max)
- {
- fprintf(stderr, "Not enough temporary memory for lines (lin space)\n");
- return 0;
- }
-
- switch (se->n_type)
- {
- case 0x24: // N_FUN: function name
- func_offset = se->n_value; // start address of function
- have_func = 1;
- break;
- case 0x44: // N_SLINE: line number in text segment
- if (have_func && (se->n_desc < 0xfffd)) // sanity check
- {
- // Search last SLINE entry and compare addresses. If they are
- // same, overwrite the last entry because we display only one
- // line number per address
- unsigned addr = se->n_value + func_offset;
-
- unsigned l = lin_end;
- while ((l > 0) && (lin_field[l-1].line>=0xfffd))
- l--;
-
- if ((l > 0) && (lin_field[l-1].addr == addr))
- {
- // found, delete array entry
- while (l < lin_end)
- {
- lin_field[l-1] = lin_field[l];
- l++;
- }
- lin_end--;
- }
- // append
- lin_field[lin_end].addr = addr;
- lin_field[lin_end].line = se->n_desc;
- lin_end++;
- }
- break;
- case 0x64: // N_SO: main file name / directory
- if (se_name_len)
- {
- if (lin_end>0 && lin_field[lin_end-1].line == 0xffff)
- {
- // mark last entry as directory, this is a file name
- lin_field[lin_end-1].line = 0xfffe;
- }
- }
- else
- have_func = 0;
- // fall through
- case 0x84: // N_SOL: name of include file
- if (se_name_len)
- {
- int type = 0xffff;
- char c = se_name[se_name_len-1];
-
- if (c=='h' || c=='H')
- type = 0xfffd; // mark as header file
-
- lin_field[lin_end].addr = se_name_idx;
- lin_field[lin_end].line = type;
- lin_end++;
- }
- break;
- }
-
- return 1;
-}
-
-static int
-add_section(const Stab_entry *se, const char *str, unsigned n)
-{
- unsigned int i;
-
- func_offset = 0;
- have_func = 0;
-
- for (i=0; i<n; i++)
- if (!add_entry(se++, str))
- return 0;
-
- return 1;
-}
-
-int
-extract_lines(unsigned char *elf_image)
-{
- Elf32_Ehdr *ehdr = (Elf32_Ehdr*)elf_image;
- Elf32_Shdr *sh_sym, *sh_str;
- const char *strtab;
- unsigned int i;
-
- // search contiguous free pages for temporary memory
- str_end = lin_end = 0;
- lin_field = (Stab_line*)malloc(lin_max);
- str_field = (char*)malloc(str_max);
-
- str_field[0] = '\0';
-
- if (ehdr->e_shstrndx == SHN_UNDEF)
- {
- fprintf(stderr, "Error in ELF header\n");
- return -3;
- }
-
- if (0 == (sh_str = elf_sh_lookup(elf_image, ehdr->e_shstrndx)))
- {
- fprintf(stderr, "Error in ELF stab section\n");
- return -3;
- }
-
- strtab = (const char*)(elf_image + sh_str->sh_offset);
-
- for (i=0; i<ehdr->e_shnum; i++)
- {
- sh_sym = elf_sh_lookup(elf_image, i);
- if ( ( sh_sym->sh_type == SHT_PROGBITS
- || sh_sym->sh_type == SHT_STRTAB)
- && (!strcmp(sh_sym->sh_name + strtab, ".stab")))
- {
- if (0 == (sh_str = elf_sh_lookup(elf_image, sh_sym->sh_link)))
- {
- fprintf(stderr, "Error in ELF stab section\n");
- return -3;
- }
-
- if (!add_section((const Stab_entry*)(elf_image+sh_sym->sh_offset),
- (const char*) (elf_image+sh_str->sh_offset),
- sh_sym->sh_size/sh_sym->sh_entsize))
- return -3;
- }
- }
-
- if (lin_end > 0)
- {
- // add terminating entry
- if (lin_end >= lin_max)
- {
- fprintf(stderr, "Not enough temporary memory for lines "
- "(terminating line entry)\n");
- return -3;
- }
- lin_field[lin_end].addr = 0;
- lin_field[lin_end].line = 0;
- lin_end++;
-
- // string offset relativ to begin of lines
- for (i=0; i<lin_end; i++)
- if (lin_field[i].line >= 0xfffd)
- lin_field[i].addr += lin_end*sizeof(Stab_line);
-
- fwrite(lin_field, lin_end*sizeof(Stab_line), 1, stdout);
- fwrite(str_field, str_end, 1, stdout);
-
- return 0;
- }
-
- fprintf(stderr, "No lines stored\n");
- return -3;
-}
-
-int
-main(int argc, char **argv)
-{
- int fd;
- unsigned size;
- unsigned char *image;
-
- if (argc != 2)
- {
- fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
- return -1;
- }
-
- if ((fd = open(argv[1], O_RDONLY)) < 0)
- {
- fprintf(stderr, "Cannot open %s\n", argv[1]);
- return -2;
- }
-
- size = lseek(fd, 0, SEEK_END);
-
- if ((image = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0))
- == (unsigned char*)-1)
- {
- fprintf(stderr, "Cannot map ELF file\n");
- return -3;
- }
-
- return extract_lines(image);
-}
-
+++ /dev/null
-INTERFACE[ia32]:
-
-#include "types.h"
-
-class Mem_unit
-{
-};
-
-
-IMPLEMENTATION[ia32]:
-
-/** Flush the whole TLB.
- */
-PUBLIC static inline
-void
-Mem_unit::tlb_flush()
-{
- unsigned dummy;
- asm volatile ("mov %%cr3,%0; mov %0,%%cr3 " : "=r"(dummy));
-}
-
-
-/** Flush TLB at virtual address.
- */
-PUBLIC static inline
-void
-Mem_unit::tlb_flush(Address addr)
-{
- asm volatile ("invlpg %0" : : "m" (*(char*)addr) : "memory");
-}
-
-PUBLIC static inline
-void
-Mem_unit::clean_dcache(void *)
-{}
+++ /dev/null
-INTERFACE[amd64]:
-
-#include "types.h"
-
-class Mem_unit
-{
-};
-
-
-IMPLEMENTATION[amd64]:
-
-/** Flush the whole TLB.
- */
-PUBLIC static inline
-void
-Mem_unit::tlb_flush()
-{
- Unsigned64 dummy;
- asm volatile ("movq %%cr3,%0; movq %0,%%cr3 " : "=r"(dummy));
-}
-
-
-/** Flush TLB at virtual address.
- */
-PUBLIC static inline
-void
-Mem_unit::tlb_flush(Address addr)
-{
- asm volatile ("invlpg %0" : : "m" (*(char*)addr) : "memory");
-}
-
-PUBLIC static inline
-void
-Mem_unit::clean_dcache(void *)
-{}
+++ /dev/null
-
-#include "config_gdt.h"
-#include "config_tcbsize.h"
-#include "globalconfig.h"
-#include "idt_init.h"
-#include <low_level.h>
-#include "shortcut.h"
-#include "tcboffset.h"
-#include "regdefs.h"
-#include "asm.h"
-
-#define L4_IPC_RECANCELED 0x40
-#define L4_IPC_RETIMEOUT 0x20
-
-#define PDIR_IDX(virt) (((virt) >> 22) & 0x3ff)
-
-/* stack layout
- SS
- ESP
- EFL
- CS
- EIP
-
- %rax
- %rbp
- %rbx
- %rdi
- %rsi
- %rdx
- %rcx
- %r8
- %r9
- %r10
- %r11
- %r12
- %r13
- %r14
- %r15
-*/
-
-
-// XXXX: let save the user r8-r14 or use them as
-// additional IPC registers (would be the best solution)
-// then we can save and restore them lazily (only
-// if we need will block. If we dont block,
-// we can leave them in place.
-
-#define OFS__THREAD__SS (THREAD_BLOCK_SIZE - 1*8)
-#define OFS__THREAD__ESP (THREAD_BLOCK_SIZE - 2*8)
-#define OFS__THREAD__EFL (THREAD_BLOCK_SIZE - 3*8)
-#define OFS__THREAD__CS (THREAD_BLOCK_SIZE - 4*8)
-#define OFS__THREAD__EIP (THREAD_BLOCK_SIZE - 5*8)
-
-// In the SYSENTER path all kernel memory accesses go through stack
-// segment ss. This way we do not need to RESET_KERNEL_SEGMENTS in
-// SMAS. The RESET_KERNEL_SEGMENTS function is executed if the shortcut
-// fails or we switch to another thread which is not in shortcut.
-
- //
- // ready_enqueue
- //
- // Here we don't check if the context which is to be enqueued is
- // not current() and has the same priority as current(). In this
- // case, Context::ready_enqueue() enqueues current() first. We
- // don't do this here but the location this macro is called from
- // has to check this.
- //
- // precondition : ecx = thread->sched()
- // rax = thread->sched()->prio() (upper 32bits 0)
- // scratches : ecx, edx
- .macro READY_ENQUEUE thread, label
- // if (prio > prio_highest)
- // prio_highest = prio
- cmp CONTEXT_PRIO_HIGHEST, %eax
- jbe 1f
- mov %eax, CONTEXT_PRIO_HIGHEST
-
-1: mov CONTEXT_PRIO_NEXT (, %rax, 8), %rdx
- // if (!prio_next[prio])
- or %rdx, %rdx
- jnz 2f
- // prio_next[prio] = this;
- mov \thread, CONTEXT_PRIO_NEXT (, %rax, 8)
- // ready_next = this;
- mov \thread, OFS__THREAD__READY_NEXT (\thread)
- // ready_prev = this;
- mov \thread, OFS__THREAD__READY_PREV (\thread)
- jmp \label
-2: // ecx = prio_next[prio]->ready_prev
- mov OFS__THREAD__READY_PREV (%rdx), %rcx
- // ready_next = prio_next[prio]
- mov %rdx, OFS__THREAD__READY_NEXT (\thread)
- // ready_prev = prio_next[prio]->ready_prev
- mov %rcx, OFS__THREAD__READY_PREV (\thread)
- // prio_next[prio]->ready_prev = this
- mov \thread, OFS__THREAD__READY_PREV (%rdx)
- // ready_prev->ready_next = this
- mov \thread, OFS__THREAD__READY_NEXT (%rcx)
- .endm
-
-
-# define KIP_SWITCH_TIME 0xA8
-# define KIP_CONSUMED_TIME 0xB8
-
- //
- // bookkeeping for the time a thread consumed
- //
- // precondition : ebx = THIS
- // esi = DEST
- // scratches : eax, ecx, edx, ebp
- .macro CONSUME_TIME
- .endm
-
-
-#ifdef CONFIG_ASSEMBLER_IPC_SHORTCUT
-
-// only dummys
-
- .globl entry_sys_ipc
-entry_sys_ipc:
- push %rax
- SAVE_STATE
- ESP_TO_TCB_AT %rbx
- RESET_THREAD_CANCEL_AT %rbx
-
-#define THIS_rbx %rbx
-
- call ipc_short_cut_wrapper
-in_slow_ipc1:
- RESTORE_STATE
- pop %rax
- iretq
- .globl in_slow_ipc1
-
-i30_ret_switch:
- .globl i30_ret_switch
-
-
-#ifndef CONFIG_PF_UX
-
-// IPC entry point for sysenter.
-
- .align 16
- .globl entry_sys_fast_ipc
- .globl entry_syscall
-entry_sys_fast_ipc:
-entry_syscall:
- mov %rsp,%r15 /* save user rsp */
- mov syscall_rsp0,%rsp /* get address of kernel stack */
- pop %rsp /* set kernel stack */
-
-/* we dont need the segment stuff */
-// push $(GDT_DATA_USER | SEL_PL_U) /* fake user ss */
- sub $8, %rsp
- push %r15 /* save user rsp */
- push %r11 /* save user rflags */
-
-// push $(GDT_CODE_USER | SEL_PL_U) /* fake user cs */
- sub $8, %rsp
- push %rcx /* save user rip */
-
- SAVE_STATE_SYSEXIT
- ESP_TO_TCB_AT %rbx
-#define THIS_rbx %rbx
- RESET_THREAD_CANCEL_AT %rbx
-
-
- // test if long send or no send at all
- test $~0, %rax
- jnz se_shortcut_failed
-
- // test if destination is L4_INVALID_ID
-
- // because the default op-size is 32 bit
- // i will use the 32bit regs if possible
- // to save the 64bit op-prefix
- // operations on the 32bit registers
- // will zero out the upper 32bits.
-
- cmp $~0, %esi
- je se_shortcut_failed
-
- // test if destination is L4_NIL_ID
- test %esi, %esi
- jz se_shortcut_failed
-
- // test if destination has ``next_period'' bit set
- movabsq $0x0020000000000000, %rcx
- test %rcx, %rsi
- jnz se_shortcut_failed
-
-// int3
-
-// at this point we need only the lower 32bits of the dest id
-// the higher bits will masked out later
-
-// the ver0 field (the lower 10bits) of the ID spawns 1024 bytes,
-// so multiply it by 4
- shl $2, %esi
- and $TCB_ADDRESS_MASK, %rsi
-
-// this works, because the kernel lies in the top of the
-// virt. address space, where all higher bits are 1
- or $VAL__MEM_LAYOUT__TCBS, %rsi // dst = dst_id.lookup
-#define DEST_rsi %rsi
-
-// int3
-
-#define RECV_DESC_rbp %rbp
-#define RECV_DESC_rbp_low %ebp
-
- // test if have receive operation
- cmp $~0, RECV_DESC_rbp
-/* je se_test_tcb_mapped // no */
- // first version will handle only send+rcv
- je se_shortcut_failed
-
- // test if short receive
- cmp $1, RECV_DESC_rbp
- ja se_shortcut_failed // more than 2 dwords
-
- // rdi contains the timeout
- // test if simple timeout
- testl $0x0f, %edi // rcv_to==inf => exp = 0
- jz 1f // rcv_to==inf => o.k.
- testl $0xff000000, %edi
- jnz se_shortcut_failed // (rcv_to!=inf) && (rcv_to!=0)
-
-1: // test if open wait and (irq attached or sender queued)
- // ebp is 0 (receive) or 1 (open wait) here
- test RECV_DESC_rbp_low, RECV_DESC_rbp_low
- jz se_test_tcb_mapped // closed wait
-
- mov OFS__THREAD__SENDER_FIRST (THIS_rbx), %rax
- test %rax, %rax
- jnz se_shortcut_failed
- or OFS__THREAD__IRQ (THIS_rbx), %rax
- jnz se_shortcut_failed
- jmp se_test_tcb_mapped
-
-// int3
- .align 8
-se_shortcut_failed:
- // shortcut failed, execute normal ipc C++ pass
- CNT_SHORTCUT_FAILED
- call sys_ipc_wrapper
-in_slow_ipc2:
- DO_SYSEXIT
-
-
- .align 16
-se_test_tcb_mapped:
-
- lea OFS__THREAD__STATE (DEST_rsi), %rcx // addr of dst tcb state
-
- // Here we could raise a pagefault. The pagefault handler notices
- // that by looking at the pagefault address. In that case the pager
- // sets the carry flag and returns immediatly.
- andl $~0, %ss:(%rcx) // can raise pagefault
- jc se_shortcut_failed_1 // tcb is not paged
-
- testl $(Thread_delayed_deadline | Thread_delayed_ipc), (%rcx)
- jnz se_shortcut_failed_1
-
- // we assume the thread state will fit in the first 32bit
- mov (%rcx), %eax
-
- and $(Thread_receiving | Thread_send_in_progress | \
- Thread_ipc_in_progress), %eax
-
- mov OFS__THREAD__PARTNER (DEST_rsi), %rdx
-
- // dst->thread_lock()->test()
- cmp $0, \
- OFS__THREAD__THREAD_LOCK__SWITCH_LOCK__LOCK_OWNER (DEST_rsi)
- jne se_shortcut_failed_1 // dst is locked
-
- lea CAST__Thread_TO_Sender (THIS_rbx), %rcx // (Sender*)this
-
- // (ipc_state == (Thread_receiving | Thread_ipc_in_progress)
- cmpb $(Thread_ipc_in_progress | Thread_receiving), %al
- jne se_shortcut_failed_1
-
- // see Receiver::sender_ok
- mov OFS__THREAD__SENDER_FIRST (DEST_rsi), %rax
-
- // if DEST_esi->partner() == 0, openwait
- test %rdx, %rdx
- jne 1f
-
- // sender_queue empty?
- test %rax, %rax
- jnz 1f
- jmp se_sender_ok
-
-1: // if DEST_esi->partner() == this, wait for me
- cmp %rcx, %rdx
- jne se_shortcut_failed_1
-
- jmp se_sender_ok
-se_shortcut_failed_1:
- jmp se_shortcut_failed
-
- .align 16
-
-se_sender_ok:
- CNT_SHORTCUT_SUCCESS
-
- // clear, we need it later
- xor %eax, %eax
-
- // wake up receiver
- andl $~(Thread_ipc_receiving_mask | \
- Thread_ipc_in_progress), OFS__THREAD__STATE (DEST_rsi)
- orb $Thread_ready, OFS__THREAD__STATE (DEST_rsi)
-
- // %eax=0 => default: no receive part => status ok
-
- // prepare a receive if we have one
- cmp $~0, RECV_DESC_rbp
- je se_do_switch_exec // no receive part
- // we should jump, because we have ruled out receiving before
-
-// int3
-
-#define REGS_rsp %rsp
- // set_rcv_regs (regs)
- mov REGS_rsp, OFS__THREAD__RCV_REGS (THIS_rbx)
-
- orb $(Thread_receiving | Thread_ipc_in_progress),\
- OFS__THREAD__STATE (THIS_rbx)
-
- // default: open wait
- xor %ecx, %ecx
-
- test RECV_DESC_rbp_low, RECV_DESC_rbp_low // open wait?
- jnz 1f // openwait cmp yes
-
- // set dst's partner
- lea CAST__Thread_TO_Sender (DEST_rsi), %rcx // (Sender*)dst
-
-1: mov %rcx, OFS__THREAD__PARTNER (THIS_rbx)
-
- // timeout = 0
- movb $L4_IPC_RETIMEOUT, %al
- testl $0x0f, %edi // rcv_to==inf => exp = 0
- jne se_do_switch_exec // timeout==inf? no
-
- // timeout = infinite ==> need wakeup
- movb $L4_IPC_RECANCELED, %al
- andb $~Thread_ready, OFS__THREAD__STATE (THIS_rbx)
-
- .align 16
-se_do_switch_exec:
-
- mov %rax, REG_RAX (REGS_rsp) // store ipc result
-
- CNT_CONTEXT_SWITCH
-
- mov OFS__THREAD__STATE (THIS_rbx), %eax
- test $Thread_fpu_owner, %eax
- jz 1f
- // set ts
- mov %cr0, %rdx
- or $CR0_TS, %rdx
- mov %rdx, %cr0
- jmp 2f
-
-1: testl $Thread_fpu_owner, OFS__THREAD__STATE (DEST_rsi)
- jz 2f
- // clear ts
- clts
-
-2: // %eax=thread_state (THIS_ebx)
- xor %edx, %edx
-
- // if (state() & Thread_ready && ! in_ready_list())
- // ready_enqueue()
- cmp %rdx, OFS__THREAD__READY_NEXT (THIS_rbx)
- jne se_no_enqueue
- testb $Thread_ready, %al
- jnz se_enqueue_this
-
- .align 8
-se_no_enqueue:
- // not for performance kernels!
- CONSUME_TIME // scratches eax, ecx, edx, ebp
-
- // push restart address onto old stack
-
-// mov $se_ret_switch, %rax
- lea se_ret_switch(%rip), %rax
- pushq %rax
-
- mov REGS_rsp, OFS__THREAD__KERNEL_SP (THIS_rbx)
-#undef REGS_rsp
-#define DEST_KERNEL_SP_rbp %rbp
- mov OFS__THREAD__KERNEL_SP (DEST_rsi), DEST_KERNEL_SP_rbp
-
- // switch esp0 on TSS
- mov CPUS_BASE + OFS__CPU__TSS, %rax
- leaq THREAD_BLOCK_SIZE (DEST_rsi), %rcx
-
- mov %rcx, 4 (%rax) // x86_tss.esp0
-
- // we dont clear the IPC window of the destination thread
- // reason: ipc already finished and the destination thread
- // will setup an new one before entering long IPC again
-
-// int3
- // pdir = space_context - kmem::mem_phys (needed later)
- movq OFS__THREAD__SPACE (DEST_rsi), %rax
- leaq OFS__SPACE__MEM_SPACE (%rax), %rax
- sub PHYSMEM_OFFS, %rax
-
- mov PAGE_DIR_ADDR, %rcx // get_pdir()
- cmp %rax, %rcx // get_pdir == pdir
- jne se_flush_pdir // no => flush
-
-se_addr_space_switched:
-
- lea se_ret_switch(%rip), %rax
- cmp %rax, (DEST_KERNEL_SP_rbp)
- jne se_slow_switch
-
- RESET_THREAD_IPC_MASK_AT DEST_rsi
-
- // Setup return registers. We have to add 8 to each %rsp,%rbp reference
- // since there is the return address pushed on the stack.
-
- mov OFS__THREAD__EIP (DEST_rsi), %rcx
- /* make RIP canonical, workaround for intel IA32e flaw */
- shl $16, %rcx
- sar $16, %rcx
- mov OFS__THREAD__ESP (DEST_rsi), %r15
- mov OFS__THREAD__EFL (DEST_rsi), %r11
- mov OFS__THREAD__ID (THIS_rbx), %rsi
-
- mov 8+REG_RDX (%rsp), %rdx
- mov 8+REG_RBX (%rsp), %rbx
- mov $RETURN_DOPE, %eax
-
- mov 8+REG_R14 (%rbp), %r14
- mov 8+REG_R13 (%rbp), %r13
- mov 8+REG_R12 (%rbp), %r12
- mov 8+REG_R10 (%rbp), %r10
- mov 8+REG_R9 (%rbp), %r9
- mov 8+REG_R8 (%rbp), %r8
-
- mov %r15, %rsp
- sysretq
-
-se_flush_pdir:
- CNT_ADDR_SPACE_SWITCH
- mov %rax, PAGE_DIR_ADDR // set pdir, flush TLBs
- jmp se_addr_space_switched
-
-se_enqueue_this:
- // ecx = sched(), eax = sched()->prio()
- mov OFS__THREAD__SCHED (THIS_rbx), %rcx
-
- xor %eax, %eax
- movl OFS__SCHED_CONTEXT__PRIO (%rcx), %eax
- READY_ENQUEUE THIS_rbx, se_no_enqueue // scratches ecx, edx
- jmp se_no_enqueue
-
- .align 16
-se_ret_switch:
- // shortcut success
- ESP_TO_TCB_AT %rbx
- RESET_THREAD_IPC_MASK_AT %rbx
- DO_SYSEXIT
-
-
- // The destination thread is not in a shortcut IPC so we cannot
- // throw it directly into user space since it may held a thread
- // lock or does not return via sysexit (int-entered IPC or
- // ex_regs manipulation)
- .align 16
-se_slow_switch:
- mov OFS__THREAD__RCV_REGS (DEST_rsi), %rax
- mov 8+REG_RDX (%rsp), %rdx
- mov 8+REG_RBX (%rsp), %rcx
- mov %rdx, REG_RDX (%rax) // dst_regs->edx = dw1
- mov %rcx, REG_RBX (%rax) // dst_regs->ebx = dw2
- mov OFS__THREAD__ID (THIS_rbx), %rdx
- movq $RETURN_DOPE, REG_RAX (%rax)
- mov %rdx, REG_RSI (%rax) // dst_regs->esi = id.low
- mov %rbp, %rsp // load new stack pointer
- pop %rax
- jmp *%rax
-
- .globl in_slow_ipc2
- .globl se_ret_switch
-
-#endif // CONFIG_PF_UX
-
- .globl in_slow_ipc1
- .globl i30_ret_switch
-
-#endif // CONFIG_ASSEMBLER_IPC_SHORTCUT
-
- // fast return from Dirq::hit
- .align 16
- .globl fast_ret_from_irq
-fast_ret_from_irq:
- RESTORE_STATE
- popq %rax
- andq $0x7f, 8(%rsp) // if entered using syscall
- orq $EFLAGS_IF, 16(%rsp) // if entered using syscall
- iretq
-
+++ /dev/null
-INTERFACE[16550]:
-
-// The port-based 16550 UART can be used before the MMU is initialized
-EXTENSION class Kernel_uart { enum { Bsp_init_mode = Init_before_mmu }; };
-
-IMPLEMENTATION[16550]:
-
-IMPLEMENT
-bool Kernel_uart::startup(unsigned port, int irq)
-{
- return Uart::startup(port, irq);
-}
+++ /dev/null
-#ifndef REGDEFS_H
-#define REGDEFS_H
-
-//
-// Register and register bit definitions for ia32, amd64 and UX architectures.
-//
-
-#define CR0_PE 0x00000001 // Protection Enable
-#define CR0_MP 0x00000002 // Monitor Coprocessor
-#define CR0_EM 0x00000004 // Emulation Coprocessor
-#define CR0_TS 0x00000008 // Task Switched
-#define CR0_ET 0x00000010 // Extension Type
-#define CR0_NE 0x00000020 // Numeric Error
-#define CR0_WP 0x00010000 // Write Protect
-#define CR0_AM 0x00040000 // Alignment Mask
-#define CR0_NW 0x20000000 // Not Write-Through
-#define CR0_CD 0x40000000 // Cache Disable
-#define CR0_PG 0x80000000 // Paging
-
-#define CR3_PWT 0x00000008 // Page-Level Write Transparent
-#define CR3_PCD 0x00000010 // Page-Level Cache Disable
-
-#define CR4_VME 0x00000001 // Virtual 8086 Mode Extensions
-#define CR4_PVI 0x00000002 // Protected Mode Virtual Ints
-#define CR4_TSD 0x00000004 // Time Stamp Disable
-#define CR4_DE 0x00000008 // Debugging Extensions
-#define CR4_PSE 0x00000010 // Page Size Extensions
-#define CR4_PAE 0x00000020 // Physical Address Extensions
-#define CR4_MCE 0x00000040 // Machine Check Exception
-#define CR4_PGE 0x00000080 // Page Global Enable
-#define CR4_PCE 0x00000100 // Perfmon Counter Enable
-#define CR4_OSFXSR 0x00000200 // OS Supports FXSAVE/FXRSTOR
-#define CR4_OSXMMEXCPT 0x00000400 // OS Supports SIMD Exceptions
-#define CR4_VMXE 0x00002000 // VMX enable
-#define CR4_OSXSAVE 0x00040000 // OS Support XSAVE
-
-#define EFLAGS_CF 0x00000001 // Carry Flag
-#define EFLAGS_PF 0x00000004 // Parity Flag
-#define EFLAGS_AF 0x00000010 // Adjust Flag
-#define EFLAGS_ZF 0x00000040 // Zero Flag
-#define EFLAGS_SF 0x00000080 // Sign Flag
-#define EFLAGS_TF 0x00000100 // Trap Flag
-#define EFLAGS_IF 0x00000200 // Interrupt Enable
-#define EFLAGS_DF 0x00000400 // Direction Flag
-#define EFLAGS_OF 0x00000800 // Overflow Flag
-#define EFLAGS_IOPL 0x00003000 // I/O Privilege Level (12+13)
-#define EFLAGS_IOPL_K 0x00000000 // kernel
-#define EFLAGS_IOPL_U 0x00003000 // user
-#define EFLAGS_NT 0x00004000 // Nested Task
-#define EFLAGS_RF 0x00010000 // Resume
-#define EFLAGS_VM 0x00020000 // Virtual 8086 Mode
-#define EFLAGS_AC 0x00040000 // Alignment Check
-#define EFLAGS_VIF 0x00080000 // Virtual Interrupt
-#define EFLAGS_VIP 0x00100000 // Virtual Interrupt Pending
-#define EFLAGS_ID 0x00200000 // Identification
-
-// CPU Feature Flags
-#define FEAT_FPU 0x00000001 // FPU On Chip
-#define FEAT_VME 0x00000002 // Virt. 8086 Mode Enhancements
-#define FEAT_DE 0x00000004 // Debugging Extensions
-#define FEAT_PSE 0x00000008 // Page Size Extension
-#define FEAT_TSC 0x00000010 // Time Stamp Counter
-#define FEAT_MSR 0x00000020 // Model Specific Registers
-#define FEAT_PAE 0x00000040 // Physical Address Extension
-#define FEAT_MCE 0x00000080 // Machine Check Exception
-#define FEAT_CX8 0x00000100 // CMPXCHG8B Instruction
-#define FEAT_APIC 0x00000200 // APIC On Chip
-#define FEAT_SEP 0x00000800 // Sysenter/Sysexit Present
-#define FEAT_MTRR 0x00001000 // Memory Type Range Registers
-#define FEAT_PGE 0x00002000 // PTE Global Bit Extension
-#define FEAT_MCA 0x00004000 // Machine Check Architecture
-#define FEAT_CMOV 0x00008000 // Conditional Move Instruction
-#define FEAT_PAT 0x00010000 // Page Attribute Table
-#define FEAT_PSE36 0x00020000 // 32 bit Page Size Extension
-#define FEAT_PSN 0x00040000 // Processor Serial Number
-#define FEAT_CLFSH 0x00080000 // CLFLUSH Instruction
-#define FEAT_DS 0x00200000 // Debug Store
-#define FEAT_ACPI 0x00400000 // Thermal Monitor & Clock
-#define FEAT_MMX 0x00800000 // MMX Technology
-#define FEAT_FXSR 0x01000000 // FXSAVE/FXRSTOR Instructions
-#define FEAT_SSE 0x02000000 // SSE
-#define FEAT_SSE2 0x04000000 // SSE2
-#define FEAT_SS 0x08000000 // Self Snoop
-#define FEAT_HTT 0x10000000 // Hyper-Threading Technology
-#define FEAT_TM 0x20000000 // Thermal Monitor
-#define FEAT_PBE 0x80000000 // Pending Break Enable
-
-// CPU Extended Feature Flags (Intel)
-#define FEATX_SSE3 0x00000001 // SSE3
-#define FEATX_MONITOR 0x00000008 // MONITOR/MWAIT Support
-#define FEATX_DSCPL 0x00000010 // CPL Qualified Debug Store
-#define FEATX_VMX 0x00000020 // Virtual Machine Extensions
-#define FEATX_EST 0x00000080 // Enhanced SpeedStep Technology
-#define FEATX_TM2 0x00000100 // Thermal Monitor 2
-#define FEATX_SSSE3 0x00000200 // SSSE3
-#define FEATX_CID 0x00000400 // L1 Context ID (adaptive/shared)
-#define FEATX_CX16 0x00002000 // CMPXCHG16B Instruction
-#define FEATX_XTPR 0x00004000 // Disable Task Priority Messages
-#define FEATX_PCID 0x00020000 // PCID
-#define FEATX_SSE4_1 0x00080000 // SSE4_1
-#define FEATX_SSE4_2 0x00100000 // SSE4_2
-#define FEATX_X2APIC 0x00200000 // x2APIC
-#define FEATX_AES 0x02000000 // AES instructions
-#define FEATX_XSAVE 0x04000000 // XSAVE
-#define FEATX_OSXSAVE 0x08000000 // OSXSAVE
-#define FEATX_AVX 0x10000000 // AVX
-
-// AMD: CPU Feature Flags, Fn80000001_ECX
-#define FEATA_SVM 0x00000004
-
-// AMD: CPU Feature Flags, Fn80000001_EDX
-#define FEATA_SYSCALL 0x00000800 // Syscall/Sysret Present
-#define FEATA_MP 0x00080000 // MP Capable
-#define FEATA_NX 0x00100000 // No-Execute Page Protection
-#define FEATA_MMXEXT 0x00400000 // AMD Extensions to MMX
-#define FEATA_LM 0x20000000 // Long Mode
-#define FEATA_3DNOWEXT 0x40000000 // AMD 3DNow! extensions
-#define FEATA_3DNOW 0x80000000 // 3DNow!
-
-// Page Fault Error Codes
-// PF_ERR_REMTADDR and PF_ERR_USERADDR are UX-emulation only
-#define PF_ERR_PRESENT 0x00000001 // PF: Page Is Present In PTE
-#define PF_ERR_WRITE 0x00000002 // PF: Page Is Write Protected
-#define PF_ERR_USERMODE 0x00000004 // PF: Caused By User Mode Code
-#define PF_ERR_RESERVED 0x00000008 // PF: Reserved Bit Set in PDIR
-#define PF_ERR_REMTADDR 0x40000000 // PF: In Remote Address Space
-#define PF_ERR_USERADDR 0x80000000 // PF: In User Address Space
-
-// Model Specific Registers
-#define MSR_TSC 0x010 // Time Stamp Counter
-#define MSR_IA32_FEATURE_CONTROL 0x03a // Control Features in Intel 64 Processor
-#define MSR_SYSENTER_CS 0x174 // Kernel Code Segment
-#define MSR_SYSENTER_ESP 0x175 // Kernel Syscall Entry
-#define MSR_SYSENTER_EIP 0x176 // Kernel Stack Pointer
-#define MSR_LER_FROM_LIP 0x1d7 // Last Exception Record From Linear
-#define MSR_LER_TO_LIP 0x1d8 // Last Exception Record To Linear
-#define MSR_DEBUGCTLA 0x1d9 // Debug Control
-#define MSR_LASTBRANCH_TOS 0x1da // (P4) Last Branch Record Stack TOS
-#define MSR_LASTBRANCH_0 0x1db // (P4) Last Branch Record 0
-#define MSR_LASTBRANCH_1 0x1dc // (P4) Last Branch Record 1
-#define MSR_LASTBRANCH_2 0x1dd // (P4) Last Branch Record 2
-#define MSR_LASTBRANCH_3 0x1de // (P4) Last Branch Record 3
-#define MSR_LASTBRANCHFROMIP 0x1db // (P6)
-#define MSR_LASTBRANCHTOIP 0x1dc // (P6)
-#define MSR_LASTINTFROMIP 0x1dd // (P6)
-#define MSR_LASTINTTOIP 0x1de // (P6)
-#define MSR_PAT 0x277 // PAT
-
-// AMD64 Model Specific Registers
-#define MSR_EFER 0xc0000080 // Extended Feature Enable Register
-#define MSR_STAR 0xc0000081 // CS and SS for Syscall/Sysret
-#define MSR_LSTAR 0xc0000082 // EIP for Syscall (64Bit-Mode)
-#define MSR_CTAR 0xc0000083 // EIP for Syscall (Comp-Mode)
-#define MSR_SFMASK 0xc0000084 // RFLAGS for Syscall
-#define MSR_FS_BASE 0xc0000100 // FS-Base
-#define MSR_GS_BASE 0xc0000101 // GS-Base
-#define MSR_VM_CR 0xc0010114 // SVM
-#define MSR_VM_HSAVE_PA 0xc0010117 // SVM host state-save area
-
-#endif
+++ /dev/null
-/**
- * \file
- */
-/*
- * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <l4/sys/kip.h>
-#include <l4/util/l4_macros.h>
-#include "panic.h"
-
-#include "macros.h"
-#include "init_kip.h"
-#include "region.h"
-#include "startup.h"
-#include <l4/sys/kip>
-
-using L4::Kip::Mem_desc;
-
-extern unsigned char _stack;
-
-/**
- * setup Kernel Info Page
- */
-void
-init_kip_v2(void *_l4i, boot_info_t *bi, l4util_mb_info_t *mbi,
- Region_list *ram, Region_list *regions)
-{
- l4_kernel_info_t *l4i = (l4_kernel_info_t *)_l4i;
-
- unsigned char l4_api = l4i->version >> 24;
-
- if (l4_api != 0x87 /*VERSION_FIASCO*/)
- panic("cannot load kernels other than Fiasco");
-
- Mem_desc *md = Mem_desc::first(_l4i);
- for (Region const* c = ram->begin(); c != ram->end(); ++c)
- (md++)->set(c->begin(), c->end(), Mem_desc::Conventional);
-
- for (Region const *c = regions->begin(); c != regions->end(); ++c)
- {
- Mem_desc::Mem_type type = Mem_desc::Reserved;
- unsigned char sub_type = 0;
- switch (c->type())
- {
- case Region::No_mem:
- case Region::Ram:
- case Region::Boot:
- continue;
- case Region::Kernel:
- type = Mem_desc::Reserved;
- break;
- case Region::Sigma0:
- type = Mem_desc::Dedicated;
- break;
- case Region::Root:
- type = Mem_desc::Bootloader;
- break;
- case Region::Arch:
- type = Mem_desc::Arch;
- sub_type = c->sub_type();
- break;
- }
- (md++)->set(c->begin(), c->end() - 1, type, sub_type);
- }
-
- l4i->user_ptr = (unsigned long)mbi;
-
- /* set up sigma0 info */
- l4i->sigma0_esp = bi->sigma0_stack;
- l4i->sigma0_eip = bi->sigma0_start;
- printf(" Sigma0 config ip:"l4_addr_fmt" sp:"l4_addr_fmt"\n",
- l4i->sigma0_eip, l4i->sigma0_esp);
-
- /* set up roottask info */
- //l4i->root_esp = (l4_umword_t) &_stack;
- l4i->root_eip = bi->roottask_start;
- printf(" Roottask config ip:"l4_addr_fmt" sp:"l4_addr_fmt"\n",
- l4i->root_eip, l4i->root_esp);
-
- /* Platform info */
- strncpy(l4i->platform_info.name, PLATFORM_TYPE,
- sizeof(l4i->platform_info.name));
- l4i->platform_info.name[sizeof(l4i->platform_info.name) - 1] = 0;
-}
+++ /dev/null
-/**
- * \file
- */
-/*
- * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>,
- * Frank Mehnert <fm3@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "init_kip.h"
-#include "startup.h"
-#include "region.h"
-#include <l4/sys/kip>
-#include <l4/sys/l4int.h>
-
-using L4::Kip::Mem_desc;
-
-/* XXX not possible to include kip.h from L4Ka::Pistachio here */
-
-#if L4_MWORD_BITS == 32
-#define V4KIP_SIGMA0_SP 0x20
-#define V4KIP_SIGMA0_IP 0x24
-#define V4KIP_SIGMA0_LOW 0x28
-#define V4KIP_SIGMA0_HIGH 0x2C
-#define V4KIP_ROOT_SP 0x40
-#define V4KIP_ROOT_IP 0x44
-#define V4KIP_ROOT_LOW 0x48
-#define V4KIP_ROOT_HIGH 0x4C
-#define V4KIP_MEM_INFO 0x54
-#define V4KIP_BOOT_INFO 0xB8
-#elif L4_MWORD_BITS == 64
-#define V4KIP_SIGMA0_SP 0x40
-#define V4KIP_SIGMA0_IP 0x48
-#define V4KIP_SIGMA0_LOW 0x50
-#define V4KIP_SIGMA0_HIGH 0x58
-#define V4KIP_ROOT_SP 0x80
-#define V4KIP_ROOT_IP 0x88
-#define V4KIP_ROOT_LOW 0x90
-#define V4KIP_ROOT_HIGH 0x98
-#define V4KIP_MEM_INFO 0xA8
-#define V4KIP_BOOT_INFO 0x170
-#else
-#error unknown architecture
-#endif
-
-#define V4KIP_WORD(kip,offset) ((l4_umword_t*)(((char*)(kip))+(offset)))
-
-/**
- * @brief Initialize KIP prototype for Fiasco/v4.
- */
-void
-init_kip_v4 (void *l4i, boot_info_t *bi, l4util_mb_info_t *mbi,
- Region_list *ram, Region_list *regions)
-{
- Mem_desc *md = Mem_desc::first(l4i);
- for (Region const* c = ram->begin(); c != ram->end(); ++c)
- (md++)->set(c->begin(), c->end(), Mem_desc::Conventional);
-
-#if 0
- // 1: all memory is accessible for users
- *p++ = 0 | 4;
- *p++ = ~0UL;
- num_info++;
-
- // 4: (additional) 20MB kernel memory
- if (mem_end > (240 << 20))
- mem_end = 240 << 20;
- *p++ = (mem_end - (20 << 20)) | 2;
- *p++ = mem_end;
- num_info++;
-#endif
-
- // VGA
- (md++)->set(0xA0000, 0xBFFFF, Mem_desc::Shared);
- // 6: BIOS
- (md++)->set(0xC0000, 0xEFFFF, Mem_desc::Shared);
-
- unsigned long s0_low = ~0UL, s0_high = 0;
- unsigned long root_low = ~0UL, root_high = 0;
-
- for (Region const *c = regions->begin(); c != regions->end(); ++c)
- {
- Mem_desc::Mem_type type = Mem_desc::Reserved;
- unsigned char sub_type = 0;
- switch (c->type())
- {
- case Region::No_mem:
- case Region::Ram:
- case Region::Boot:
- continue;
- case Region::Kernel:
- type = Mem_desc::Reserved;
- break;
- case Region::Sigma0:
- type = Mem_desc::Dedicated;
- if (s0_low > c->begin())
- s0_low = c->begin();
- if (s0_high < c->end())
- s0_high = c->end();
- break;
- case Region::Root:
- type = Mem_desc::Bootloader;
- if (root_low > c->begin())
- root_low = c->begin();
- if (root_high < c->end())
- root_high = c->end();
- break;
- case Region::Arch:
- type = Mem_desc::Arch;
- sub_type = c->sub_type();
- break;
- }
- (md++)->set(c->begin(), c->end() - 1, type, sub_type);
- }
-
- *V4KIP_WORD(l4i,V4KIP_SIGMA0_LOW) = s0_low;
- *V4KIP_WORD(l4i,V4KIP_SIGMA0_HIGH) = s0_high+1;
- *V4KIP_WORD(l4i,V4KIP_SIGMA0_IP) = bi->sigma0_start;
-
- *V4KIP_WORD(l4i,V4KIP_ROOT_LOW) = root_low;
- *V4KIP_WORD(l4i,V4KIP_ROOT_HIGH) = root_high+1;
- *V4KIP_WORD(l4i,V4KIP_ROOT_IP) = bi->roottask_start;
- *V4KIP_WORD(l4i,V4KIP_ROOT_SP) = bi->roottask_stack;
-
- *V4KIP_WORD(l4i,V4KIP_BOOT_INFO) = (unsigned long)mbi;
-
- // set the mem_info variable: count of mem descriptors
- Mem_desc::count(l4i, md - Mem_desc::first(l4i));
-}
+++ /dev/null
-/*
- * (c) 2008-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-/*
- * Used when our boot loader does not supply a mbi structure.
- */
-
-#include <stdio.h>
-
-#include "loader_mbi.h"
-
-static l4util_mb_info_t my_loader_mbi;
-
-l4util_mb_info_t *loader_mbi()
-{
- return &my_loader_mbi;
-}
-
-void loader_mbi_add_cmdline(const char *cmdline)
-{
- my_loader_mbi.cmdline = (l4_uint32_t)(unsigned long)cmdline;
- my_loader_mbi.flags |= L4UTIL_MB_CMDLINE;
-}
-
-#ifdef REALMODE_LOADING
-l4util_mb_info_t *init_loader_mbi_x86_realmode(void *realmode_pointer)
-{
- my_loader_mbi.flags |= L4UTIL_MB_MEMORY;
- my_loader_mbi.mem_lower = 0x9f * 4;
-
- unsigned long *cmd_line_ptr;
-
- my_loader_mbi.mem_upper = *(unsigned long *)((char *)realmode_pointer + 0x1e0);
- printf("Detected memory size: %dKB\n", my_loader_mbi.mem_upper);
-
- cmd_line_ptr = (unsigned long *)((char *)realmode_pointer + 0x228);
- if (cmd_line_ptr && *cmd_line_ptr)
- {
- my_loader_mbi.flags |= L4UTIL_MB_CMDLINE;
- my_loader_mbi.cmdline = *cmd_line_ptr;
- }
-
- return &my_loader_mbi;
-}
-#endif
+++ /dev/null
-/*
- * (c) 2008-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#ifndef __BOOTSTRAP__LOADER_MBI_H__
-#define __BOOTSTRAP__LOADER_MBI_H__
-
-#include <l4/util/mb_info.h>
-
-l4util_mb_info_t *loader_mbi();
-void loader_mbi_add_cmdline(const char *cmdline);
-#ifdef REALMODE_LOADING
-l4util_mb_info_t *init_loader_mbi_x86_realmode(void *);
-#endif
-
-#endif /* ! __BOOTSTRAP__LOADER_MBI_H__ */
+++ /dev/null
-/*
- * (c) 2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include <cstdio>
-#include <cstdlib>
-
-#include "debug.h"
-#include "pci.h"
-#include "acpi_l4.h"
-#include "__acpi.h"
-#include "cfg.h"
-#include "main.h"
-#include "phys_space.h"
-
-extern "C" {
-#include "acpi.h"
-#include "accommon.h"
-#include "acresrc.h"
-#include "acnamesp.h"
-}
-
-#include <errno.h>
-#include <l4/cxx/list>
-
-#define _COMPONENT ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME("l4main");
-
-namespace {
-
-struct Prt_entry : public cxx::List_item
-{
- unsigned slot;
- unsigned char pin;
- acpica_pci_irq irq;
-};
-
-class Acpi_pci_irq_router_rs : public Resource_space
-{
-public:
- Prt_entry *_prt;
-
-public:
- Acpi_pci_irq_router_rs() : _prt(0) {}
-
- int add_prt_entry(ACPI_HANDLE obj, ACPI_PCI_ROUTING_TABLE *e);
- int find(int device, int pin, struct acpica_pci_irq **irq);
- bool request(Resource *parent, Device *, Resource *child, Device *cdev);
- bool alloc(Resource *, Device *, Resource *, Device *, bool)
- { return false; }
-};
-
-
-bool
-Acpi_pci_irq_router_rs::request(Resource *parent, Device *,
- Resource *child, Device *cdev)
-{
- if (dlevel(DBG_ALL))
- {
- printf("requesting IRQ resource: ");
- cdev->dump(2);
- child->dump(2);
- printf(" at ACPI IRQ routing resource\n");
- }
-
- Hw::Device *cd = dynamic_cast<Hw::Device*>(cdev);
-
- if (!cd)
- return false;
-
- struct acpica_pci_irq *irq = 0;
-
- if (find(cd->adr() >> 16, child->start(), &irq) < 0)
- return false;
-
- if (!irq)
- return false;
-
- child->del_flags(Resource::F_relative);
- child->start(irq->irq);
- child->del_flags(Resource::Irq_type_mask);
- unsigned flags = Resource::Irq_type_base;
- flags |= (!irq->trigger) * Resource::Irq_type_base * L4_IRQ_F_LEVEL;
- flags |= (!!irq->polarity) * Resource::Irq_type_base * L4_IRQ_F_NEG;
- child->add_flags(flags);
-
- child->parent(parent);
-
- return true;
-}
-
-enum Acpi_irq_model_id {
- ACPI_IRQ_MODEL_PIC = 0,
- ACPI_IRQ_MODEL_IOAPIC,
- ACPI_IRQ_MODEL_IOSAPIC,
- ACPI_IRQ_MODEL_PLATFORM,
- ACPI_IRQ_MODEL_COUNT
-};
-
-static ACPI_STATUS
-get_irq_cb(ACPI_RESOURCE *res, void *ctxt)
-{
- acpica_pci_irq *irq = (acpica_pci_irq*)ctxt;
- if (!res)
- return AE_OK;
-
- switch (res->Type)
- {
- case ACPI_RESOURCE_TYPE_IRQ:
- irq->irq = res->Data.Irq.Interrupts[0];
- irq->polarity = res->Data.Irq.Polarity;
- irq->trigger = res->Data.Irq.Triggering;
- return AE_OK;
-
- case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
- irq->irq = res->Data.ExtendedIrq.Interrupts[0];
- irq->polarity = res->Data.ExtendedIrq.Polarity;
- irq->trigger = res->Data.ExtendedIrq.Triggering;
- return AE_OK;
-
- default:
- return AE_OK;
- }
-}
-
-int
-Acpi_pci_irq_router_rs::add_prt_entry(ACPI_HANDLE obj,
- ACPI_PCI_ROUTING_TABLE *e)
-{
- if (!e)
- return -EINVAL;
-
- Prt_entry *ne = new Prt_entry();
- if (!ne)
- return -ENOMEM;
-
- ne->slot = (e->Address >> 16) & 0xffff;
- ne->pin = e->Pin;
-
- ne->irq.irq = e->SourceIndex;
- ne->irq.polarity = ACPI_ACTIVE_LOW;
- ne->irq.trigger = ACPI_LEVEL_SENSITIVE;
- if (e->Source[0])
- {
- ACPI_HANDLE link;
- d_printf(DBG_DEBUG, " (dev[%s][%d]) ", e->Source, e->SourceIndex);
- ACPI_STATUS status;
- status = AcpiGetHandle(obj, e->Source, &link);
- if (ACPI_FAILURE(status))
- {
- d_printf(DBG_WARN, "\nWARNING: Could not find PCI IRQ Link Device...\n");
- return -ENODEV;
- }
-
- status = AcpiWalkResources(link, (char*)"_CRS", get_irq_cb, &ne->irq);
- if (ACPI_FAILURE(status))
- {
- d_printf(DBG_WARN, "\nWARNING: Could not evaluate _CRS of PCI IRQ Link Device\n");
- return -ENODEV;
- }
- }
-
- _prt = cxx::List_item::push_back(_prt, ne);
- return 0;
-}
-
-int
-Acpi_pci_irq_router_rs::find(int device, int pin, struct acpica_pci_irq **irq)
-{
- Prt_entry::T_iter<Prt_entry> c = _prt;
- while (*c)
- {
- if (c->slot == (unsigned)device && c->pin == pin)
- {
- *irq = &c->irq;
- return 0;
- }
-
- ++c;
- }
-
- return -ENODEV;
-}
-
-
-static int acpi_bus_init_irq(void)
-{
- ACPI_STATUS status = AE_OK;
- ACPI_OBJECT arg = { ACPI_TYPE_INTEGER };
- ACPI_OBJECT_LIST arg_list = { 1, &arg };
- char const *message = NULL;
-
-
- //int acpi_irq_model = ACPI_IRQ_MODEL_PIC;
- int acpi_irq_model = ACPI_IRQ_MODEL_IOAPIC;
- /*
- * Let the system know what interrupt model we are using by
- * evaluating the \_PIC object, if exists.
- */
-
- switch (acpi_irq_model) {
- case ACPI_IRQ_MODEL_PIC:
- message = "PIC";
- break;
- case ACPI_IRQ_MODEL_IOAPIC:
- message = "IOAPIC";
- break;
- case ACPI_IRQ_MODEL_IOSAPIC:
- message = "IOSAPIC";
- break;
- case ACPI_IRQ_MODEL_PLATFORM:
- message = "platform specific model";
- break;
- default:
- d_printf(DBG_ERR, "ERROR: Unknown interrupt routing model\n");
- return -1;
- }
-
- d_printf(DBG_INFO, "Using %s for interrupt routing\n", message);
-
- arg.Integer.Value = acpi_irq_model;
-
- status = AcpiEvaluateObject(NULL, (char*)"\\_PIC", &arg_list, NULL);
- if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
- ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
- return -1;
- }
-
- return 0;
-}
-
-
-struct Discover_ctxt
-{
- Hw::Device *last_device;
- Hw::Device *current_bus;
- unsigned level;
-};
-
-class Acpi_res_discover : public Hw::Discover_res_if
-{
-public:
- Acpi_res_discover(ACPI_HANDLE obj) : obj(obj) {}
-
- void discover_resources(Hw::Device *host);
- void setup_resources(Hw::Device *) {}
-
-private:
- void discover_prt(Hw::Device *host);
- void discover_crs(Hw::Device *host);
-
- ACPI_HANDLE obj;
-};
-
-void
-Acpi_res_discover::discover_prt(Hw::Device *host)
-{
- ACPI_BUFFER buf;
- ACPI_STATUS status;
- ACPI_HANDLE handle;
-
- status = AcpiGetHandle(obj, (char*)"_PRT", &handle);
-
- // no PRT!!
- if (ACPI_FAILURE(status))
- {
- Resource *r = new Pci_irq_router_res<Pci_pci_bridge_irq_router_rs>();
- host->add_resource(r);
- return;
- }
-
-#if 0
- ret_buf.Length = sizeof (buffer);
- ret_buf.Pointer = buffer;
-
- status = AcpiGetName (obj, ACPI_FULL_PATHNAME, &ret_buf);
-
- if (ACPI_FAILURE (status))
- AcpiOsPrintf ("Could not convert name to pathname\n");
- else
- AcpiOsPrintf ("ACPI: PCI IRQ routing [%s._PRT]\n", buffer);
-#endif
-
- buf.Length = ACPI_ALLOCATE_BUFFER;
-
- status = AcpiGetIrqRoutingTable(obj, &buf);
-
- if (ACPI_FAILURE(status))
- {
- d_printf(DBG_ERR, "ERROR: while getting PRT for [%s]\n", "buffer");
- Resource *r = new Pci_irq_router_res<Pci_pci_bridge_irq_router_rs>();
- host->add_resource(r);
- return;
- }
-
- typedef Pci_irq_router_res<Acpi_pci_irq_router_rs> Irq_res;
- Irq_res *r = new Irq_res();
-
- char *p = (char*)buf.Pointer;
- char *e = (char*)buf.Pointer + buf.Length;
- while (1)
- {
- ACPI_PCI_ROUTING_TABLE *prt = (ACPI_PCI_ROUTING_TABLE *)p;
- if (prt->Length == 0)
- break;
-
- if (p + prt->Length > e)
- break;
-
- int err = r->provided()->add_prt_entry(obj, prt);
- if (err < 0)
- return;
-
- p += prt->Length;
- }
-
- host->add_resource(r);
-}
-
-static unsigned acpi_adr_t_to_f(unsigned art)
-{
- switch (art)
- {
- case ACPI_MEMORY_RANGE: return Resource::Mmio_res;
- case ACPI_IO_RANGE: return Resource::Io_res;
- case ACPI_BUS_NUMBER_RANGE: return Resource::Bus_res;
- default: return ~0;
- }
-}
-
-static void
-acpi_adr_res(Hw::Device *host, ACPI_RESOURCE_ADDRESS const *ar, l4_uint64_t s, l4_uint64_t l,
- bool qw)
-{
- unsigned flags = acpi_adr_t_to_f(ar->ResourceType)
- | Resource::F_fixed_size | Resource::F_fixed_addr;
-
- if (flags == ~0U)
- return;
-
- if (qw)
- flags |= Resource::F_width_64bit;
-
- Resource *r;
- if (ar->ProducerConsumer == ACPI_PRODUCER)
- r = new Resource_provider(flags, s, s + l - 1);
- else
- r = new Resource(flags, s, s + l -1);
-
- host->add_resource(r);
-}
-
-void
-Acpi_res_discover::discover_crs(Hw::Device *host)
-{
- ACPI_BUFFER buf;
- buf.Length = ACPI_ALLOCATE_BUFFER;
-
- if (ACPI_FAILURE(AcpiGetCurrentResources(obj, &buf)))
- return;
-
- char const *p = (char const *)buf.Pointer;
- while (p)
- {
- ACPI_RESOURCE const *r = (ACPI_RESOURCE const *)p;
- ACPI_RESOURCE_DATA const *d = &r->Data;
- unsigned flags = 0;
-
- switch (r->Type)
- {
- case ACPI_RESOURCE_TYPE_END_TAG:
- AcpiOsFree(buf.Pointer);
- return;
-
- case ACPI_RESOURCE_TYPE_IRQ:
- flags = Resource::Irq_res | Resource::Irq_type_base;
- flags |= (!d->Irq.Triggering) * Resource::Irq_type_base * L4_IRQ_F_LEVEL;
- flags |= (!!d->Irq.Polarity) * Resource::Irq_type_base * L4_IRQ_F_NEG;
- for (unsigned c = 0; c < d->Irq.InterruptCount; ++c)
- host->add_resource(new Resource(flags, d->Irq.Interrupts[c],
- d->Irq.Interrupts[c]));
- break;
-
- case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
- flags = Resource::Irq_res | Resource::Irq_type_base;
- flags |= (!d->ExtendedIrq.Triggering) * Resource::Irq_type_base * L4_IRQ_F_LEVEL;
- flags |= (!!d->ExtendedIrq.Polarity) * Resource::Irq_type_base * L4_IRQ_F_NEG;
- if (d->ExtendedIrq.ResourceSource.StringPtr)
- {
- d_printf(DBG_DEBUG2, "hoo indirect IRQ resource found src=%s idx=%d\n",
- d->ExtendedIrq.ResourceSource.StringPtr,
- d->ExtendedIrq.ResourceSource.Index);
- }
- else
- {
- for (unsigned c = 0; c < d->ExtendedIrq.InterruptCount; ++c)
- host->add_resource(new Resource(flags, d->ExtendedIrq.Interrupts[c],
- d->ExtendedIrq.Interrupts[c]));
- }
- break;
-
- case ACPI_RESOURCE_TYPE_IO:
- flags = Resource::Io_res | Resource::F_fixed_size | Resource::F_fixed_addr;
- host->add_resource(new Resource(flags, d->Io.Minimum,
- d->Io.Minimum + d->Io.AddressLength - 1));
- break;
-
- case ACPI_RESOURCE_TYPE_FIXED_IO:
- flags = Resource::Io_res | Resource::F_fixed_size | Resource::F_fixed_addr;
- host->add_resource(new Resource(flags, d->FixedIo.Address,
- d->FixedIo.Address + d->FixedIo.AddressLength - 1));
- break;
-
- case ACPI_RESOURCE_TYPE_MEMORY24:
- flags = Resource::Mmio_res | Resource::F_fixed_size | Resource::F_fixed_addr;
- host->add_resource(new Resource(flags, d->Memory24.Minimum,
- d->Memory24.Minimum + d->Memory24.AddressLength - 1));
- break;
-
- case ACPI_RESOURCE_TYPE_MEMORY32:
- flags = Resource::Mmio_res | Resource::F_fixed_size | Resource::F_fixed_addr;
- host->add_resource(new Resource(flags, d->Memory32.Minimum,
- d->Memory32.Minimum + d->Memory32.AddressLength - 1));
- break;
-
- case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
- flags = Resource::Mmio_res | Resource::F_fixed_size | Resource::F_fixed_addr;
- host->add_resource(new Resource(flags, d->FixedMemory32.Address,
- d->FixedMemory32.Address + d->FixedMemory32.AddressLength - 1));
- break;
-
- case ACPI_RESOURCE_TYPE_ADDRESS16:
- acpi_adr_res(host, &d->Address, d->Address16.Minimum, d->Address16.AddressLength, 0);
- break;
-
- case ACPI_RESOURCE_TYPE_ADDRESS32:
- acpi_adr_res(host, &d->Address, d->Address32.Minimum, d->Address32.AddressLength, 0);
- break;
-
- case ACPI_RESOURCE_TYPE_ADDRESS64:
- acpi_adr_res(host, &d->Address, d->Address64.Minimum, d->Address64.AddressLength, 1);
- break;
-
- default:
- d_printf(DBG_WARN, "WARNING: ignoring ACPI resource (unkown type: %d)\n", r->Type);
- break;
-
-
- }
-
- p += r->Length;
- }
-
- AcpiOsFree(buf.Pointer);
-}
-
-void
-Acpi_res_discover::discover_resources(Hw::Device *host)
-{
- Pci_bridge *bridge = dynamic_cast<Pci_bridge*>(host->discover_bus_if());
- if (bridge)
- discover_prt(host);
-
- discover_crs(host);
-
- if (bridge)
- {
- for (Resource_list::const_iterator i = host->resources()->begin();
- i != host->resources()->end(); ++i)
- {
- if ((*i)->type() == Resource::Bus_res)
- bridge->num = bridge->subordinate = (*i)->start();
- }
- }
-}
-
-
-static l4_uint32_t
-get_adr(ACPI_HANDLE dev)
-{
- ACPI_HANDLE adr;
- if (ACPI_FAILURE(AcpiGetHandle(dev, const_cast<char*>("_ADR"), &adr)))
- return ~0U;
-
- ACPI_OBJECT adro;
- ACPI_BUFFER ret_buf;
- ret_buf.Pointer = &adro;
- ret_buf.Length = sizeof(adro);
- if (ACPI_SUCCESS(AcpiEvaluateObject(adr, NULL, NULL, &ret_buf)))
- {
- switch (adro.Type)
- {
- case ACPI_TYPE_INTEGER:
- return adro.Integer.Value;
- default:
- return ~0;
- }
- }
-
- return ~0;
-}
-
-static void
-get_name(ACPI_HANDLE dev, Hw::Device *hd)
-{
- char str[5];
- ACPI_BUFFER buf;
- buf.Pointer = &str;
- buf.Length = sizeof(str);
- if (ACPI_SUCCESS(AcpiGetName(dev, ACPI_SINGLE_NAME, &buf)))
- hd->set_name(str);
-}
-
-
-static ACPI_STATUS
-discover_pre_cb(ACPI_HANDLE obj, UINT32 nl, void *ctxt, void **)
-{
- Discover_ctxt *c = reinterpret_cast<Discover_ctxt*>(ctxt);
-
- if (nl == 1)
- return AE_OK;
-
- if (nl > c->level)
- {
- c->current_bus = c->last_device;
- c->level = nl;
- }
-
- l4_uint32_t adr = get_adr(obj);
-
- Hw::Device *nd = c->current_bus->get_child_dev_uid((l4_umword_t)obj, adr, true);
- c->last_device = nd;
-
- get_name(obj, nd);
-
- ACPI_PNP_DEVICE_ID *hid = 0;
- ACPI_PNP_DEVICE_ID_LIST *cid = 0;
- bool pci_rb = false;
-#if 0
- if (ACPI_FAILURE(AcpiUtAcquireMutex(ACPI_MTX_NAMESPACE)))
- return AE_OK;
-#endif
-
- ACPI_NAMESPACE_NODE *node = AcpiNsValidateHandle(obj);
- if (!node)
- {
- //AcpiUtReleaseMutex(ACPI_MTX_NAMESPACE);
- return AE_OK;
- }
-
- if (ACPI_SUCCESS(AcpiUtExecute_HID(node, &hid)))
- {
- nd->set_hid(hid->String);
- pci_rb |= AcpiUtIsPciRootBridge(hid->String);
- ACPI_FREE(hid);
- }
-
- if (ACPI_SUCCESS(AcpiUtExecute_CID(node, &cid)))
- {
- for (unsigned i = 0; i < cid->Count; ++i)
- {
- nd->add_cid(cid->Ids[i].String);
- pci_rb |= AcpiUtIsPciRootBridge(cid->Ids[i].String);
- }
- ACPI_FREE(cid);
- }
-
-
- //AcpiUtReleaseMutex(ACPI_MTX_NAMESPACE);
-
- // hm, this seems very specific for PCI
- if (pci_rb)
- {
- d_printf(DBG_DEBUG, "Found PCI root bridge...\n");
- if (Pci_root_bridge *rb = pci_root_bridge(0))
- {
- if (rb->host())
- {
- // we found a second root bridge
- // create a new root pridge instance
- rb = new Pci_port_root_bridge(-1, nd);
- }
- else
- rb->set_host(nd);
-
- nd->set_discover_bus_if(rb);
- }
- else
- d_printf(DBG_ERR, "ERROR: there is no PCI bus driver for this platform\n");
- }
-
- nd->add_resource_discoverer(new Acpi_res_discover(obj));
-
- return AE_OK;
-}
-
-static ACPI_STATUS
-discover_post_cb(ACPI_HANDLE, UINT32 nl, void *ctxt, void **)
-{
- Discover_ctxt *c = reinterpret_cast<Discover_ctxt*>(ctxt);
- if (nl < c->level)
- {
- c->level = nl;
- c->current_bus = c->current_bus->parent();
- }
- return AE_OK;
-}
-
-}
-
-
-int acpica_init()
-{
- d_printf(DBG_INFO, "Hello from L4-ACPICA\n");
-
- pci_register_root_bridge(0, new Pci_port_root_bridge(0, 0));
-
- AcpiDbgLevel =
- ACPI_LV_INIT
- //| ACPI_LV_INFO
- // | ACPI_LV_FUNCTIONSkern/irq.cpp
- // | ACPI_LV_ALL_EXCEPTIONS
- // | ACPI_LV_LOAD
- // | ACPI_LV_INIT_NAMES
- | ACPI_LV_TABLES
- // | ACPI_LV_RESOURCES
- // | ACPI_LV_NAMES
- // | ACPI_LV_VALUES
- // | ACPI_LV_OPREGION
- | ACPI_LV_VERBOSE_INFO
- // | ACPI_LV_PARSE
- // | ACPI_LV_DISPATCH
- // | ACPI_LV_EXEC
- // | ACPI_LV_IO
- ;
-
-//0. enable workarounds, see include/acglobals.h
- AcpiGbl_EnableInterpreterSlack = (1==1);
- ACPI_STATUS status;
-
- status = AcpiInitializeSubsystem();
- if(status!=AE_OK)
- return status;
-
- status = AcpiInitializeTables (0, 0, TRUE);
- if(status!=AE_OK)
- return status;
-
- status = AcpiReallocateRootTable ();
-// if(status!=AE_OK)
-// return status;
-
- status = AcpiLoadTables ();
-
- if(ACPI_FAILURE(status))
- return status;
-
- d_printf(DBG_DEBUG, "enable ACPI subsystem\n");
- status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION);
-
- if (ACPI_FAILURE(status))
- {
- d_printf(DBG_ERR, "Unable to start the ACPI Interpreter\n");
- exit(status);
- }
-
- d_printf(DBG_DEBUG, "initialize ACPI objects\n");
- status = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION);
- if (ACPI_FAILURE(status)) {
- d_printf(DBG_ERR, "Unable to initialize ACPI objects\n");
- exit(status);
- }
-
- d_printf(DBG_DEBUG, "Interpreter enabled\n");
-
- Discover_ctxt c;
- c.last_device = system_bus();
- c.current_bus = system_bus();
- c.level = 1;
-
-
- d_printf(DBG_DEBUG, "scanning for PCI root bridge\n");
- status = AcpiWalkNamespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
- ACPI_UINT32_MAX,
- discover_pre_cb, discover_post_cb, &c, 0);
-
- /*
- * Get the system interrupt model and evaluate \_PIC.
- */
- int result = acpi_bus_init_irq();
- if (result)
- {
- d_printf(DBG_ERR, "Could not initialize ACPI IRQ stuff\n");
- exit(1);
- }
- status = AcpiSubsystemStatus();
-
- if (ACPI_FAILURE(status))
- exit(status);
-
- d_printf(DBG_INFO, "ACPI subsystem initialized\n");
-
- ACPI_BUFFER ret_buffer;
- ret_buffer.Length = ACPI_ALLOCATE_BUFFER;
-
- status = AcpiGetSystemInfo(&ret_buffer);
-
- if(ACPI_FAILURE(status))
- exit(status);
-
- acpi_print_system_info(ret_buffer.Pointer);
-
- AcpiOsFree(ret_buffer.Pointer);
-
- return 0;
-}
-
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#include <l4/sys/compiler.h>
-#include <l4/sigma0/sigma0.h>
-
-#include "debug.h"
-
-__BEGIN_DECLS
-#include "acpi.h"
-#include "acpiosxf.h"
-__END_DECLS
-
-#include "pci.h"
-#include "res.h"
-
-#if defined(ARCH_amd64) || defined(ARCH_x86)
-
-#include <l4/util/port_io.h>
-#define DEBUG_OSL_PORT_IO 0
-/*
- * Platform and hardware-independent I/O interfaces
- */
-ACPI_STATUS
-AcpiOsReadPort (
- ACPI_IO_ADDRESS address,
- UINT32 *value,
- UINT32 width)
-{
- if(DEBUG_OSL_PORT_IO)
- d_printf(DBG_ALL, "IN: adr=0x%x, width=%i\n", address, width);
-
- if (address == 0x80)
- return AE_OK;
-
- switch (width)
- {
- case 8:
- if (res_get_ioport(address, 0) < 0)
- return AE_BAD_PARAMETER;
- *value = l4util_in8((l4_uint16_t)address);
- break;
- case 16:
- if (res_get_ioport(address, 1) < 0)
- return AE_BAD_PARAMETER;
- *value = l4util_in16((l4_uint16_t)address);
- break;
- case 32:
- if (res_get_ioport(address, 2) < 0)
- return AE_BAD_PARAMETER;
- *value = l4util_in32((l4_uint16_t)address);
- break;
- default :
- return AE_BAD_PARAMETER;
- }
- if(DEBUG_OSL_PORT_IO)
- d_printf(DBG_ALL, "\tport(0x%x)=>0x%x\n",address,*value);
- return AE_OK;
-}
-
-ACPI_STATUS
-AcpiOsWritePort (
- ACPI_IO_ADDRESS address,
- UINT32 value,
- UINT32 width)
-{
- if (DEBUG_OSL_PORT_IO)
- d_printf(DBG_ALL, "\tport(0x%x)<=0x%x\n",address,value);
-
- if (address == 0x80)
- return AE_OK;
-
- switch (width)
- {
- case 8:
- if (res_get_ioport(address, 0) < 0)
- return AE_BAD_PARAMETER;
- l4util_out8((l4_uint8_t)value,(l4_uint16_t)address);
- break;
- case 16:
- if (res_get_ioport(address, 1) < 0)
- return AE_BAD_PARAMETER;
- l4util_out16((l4_uint16_t)value,(l4_uint16_t)address);
- break;
- case 32:
- if (res_get_ioport(address, 2) < 0)
- return AE_BAD_PARAMETER;
- l4util_out32((l4_uint32_t)value,(l4_uint32_t)address);
- break;
- default :
- return AE_BAD_PARAMETER;
- }
- return AE_OK;
-}
-#else
-
-ACPI_STATUS
-AcpiOsReadPort (
- ACPI_IO_ADDRESS /*address*/,
- UINT32 * /*value*/,
- UINT32 /*width*/)
-{
- return AE_NO_MEMORY;
-}
-
-ACPI_STATUS
-AcpiOsWritePort (
- ACPI_IO_ADDRESS /*address*/,
- UINT32 /*value*/,
- UINT32 /*width*/)
-{
- return AE_NO_MEMORY;
-}
-#endif
-
-void *
-AcpiOsMapMemory (
- ACPI_PHYSICAL_ADDRESS where,
- ACPI_SIZE length)
-{
- void *virt = (void*)res_map_iomem(where, length);
-
- d_printf(DBG_DEBUG, "%s(%x, %x) = %lx\n", __func__, where, length, (unsigned long)virt);
-
- return virt;
-}
-
-void
-AcpiOsUnmapMemory (
- void *logical_address,
- ACPI_SIZE size)
-{
- (void)logical_address;
- (void)size;
-// l4io_release_iomem((l4_addr_t)logical_address, size);
- return;
-}
-
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiOsReadPciConfiguration
- *
- * PARAMETERS: PciId Seg/Bus/Dev
- * Register Device Register
- * Value Buffer where value is placed
- * Width Number of bits
- *
- * RETURN: Status
- *
- * DESCRIPTION: Read data from PCI configuration space
- *
- *****************************************************************************/
-
-extern inline
-l4_uint32_t
-pci_conf_addr(l4_uint32_t bus, l4_uint32_t dev, l4_uint32_t fn, l4_uint32_t reg)
-{ return 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3); }
-
-ACPI_STATUS
-AcpiOsReadPciConfiguration (
- ACPI_PCI_ID *PciId,
- UINT32 Register,
- UINT64 *Value,
- UINT32 Width)
-{
- //printf("%s: ...\n", __func__);
- Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
- if (!rb)
- return AE_BAD_PARAMETER;
-
- int r = rb->cfg_read(PciId->Bus, (PciId->Device << 16) | PciId->Function,
- Register, (l4_uint32_t *)Value, Hw::Pci::cfg_w_to_o(Width));
-
- if (r < 0)
- return AE_BAD_PARAMETER;
-
- return AE_OK;
-}
-
-
-/******************************************************************************
- *
- * FUNCTION: AcpiOsWritePciConfiguration
- *
- * PARAMETERS: PciId Seg/Bus/Dev
- * Register Device Register
- * Value Value to be written
- * Width Number of bits
- *
- * RETURN: Status.
- *
- * DESCRIPTION: Write data to PCI configuration space
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsWritePciConfiguration (
- ACPI_PCI_ID *PciId,
- UINT32 Register,
- ACPI_INTEGER Value,
- UINT32 Width)
-{
- //printf("%s: ...\n", __func__);
- Pci_root_bridge *rb = pci_root_bridge(PciId->Segment);
- if (!rb)
- return AE_BAD_PARAMETER;
-
- int r = rb->cfg_write(PciId->Bus, (PciId->Device << 16) | PciId->Function,
- Register, Value, Hw::Pci::cfg_w_to_o(Width));
-
- if (r < 0)
- return AE_BAD_PARAMETER;
-
- return AE_OK;
-
- return (AE_OK);
-}
-
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include <l4/sys/types.h>
-#include <l4/cxx/string>
-#include <l4/cxx/minmax>
-#include <l4/io/pciids.h>
-
-#include <cstdio>
-#include <typeinfo>
-
-#include "debug.h"
-#include "main.h"
-#include "pci.h"
-#include "phys_space.h"
-#include "cfg.h"
-#include "hw_msi.h"
-
-static Pci_root_bridge *__pci_root_bridge;
-static unsigned _last_msi;
-
-class Pci_cardbus_bridge : public Pci_pci_bridge_basic
-{
-public:
- Pci_cardbus_bridge(Hw::Device *host, Pci_bridge *bus)
- : Pci_pci_bridge_basic(host, bus)
- {}
-
- void discover_resources(Hw::Device *host);
-};
-
-Pci_root_bridge *pci_root_bridge(int segment)
-{
- if (segment != 0)
- return 0;
- return __pci_root_bridge;
-}
-
-#if defined(ARCH_x86) || defined(ARCH_amd64)
-
-#include <l4/util/port_io.h>
-
-int
-pci_register_root_bridge(int segment, Pci_root_bridge *b)
-{
- if (segment != 0)
- return -1;
-
- __pci_root_bridge = b;
- return 0;
-}
-
-
-int
-Pci_port_root_bridge::cfg_read(Cfg_addr addr, l4_uint32_t *value, Cfg_width w)
-{
- l4util_out32((addr.to_compat_addr() | 0x80000000) & ~3UL, 0xcf8);
- using namespace Hw::Pci;
-
- switch (w)
- {
- case Cfg_byte: *value = l4util_in8(0xcfc + addr.reg_offs(w)); break;
- case Cfg_short: *value = l4util_in16(0xcfc + addr.reg_offs(w)); break;
- case Cfg_long: *value = l4util_in32(0xcfc); break;
- }
- return 0;
-}
-
-int
-Pci_port_root_bridge::cfg_write(Cfg_addr addr, l4_uint32_t value, Cfg_width w)
-{
- l4util_out32((addr.to_compat_addr() | 0x80000000) & ~3UL, 0xcf8);
- using namespace Hw::Pci;
-
- switch (w)
- {
- case Cfg_byte: l4util_out8(value, 0xcfc + addr.reg_offs(w)); break;
- case Cfg_short: l4util_out16(value, 0xcfc + addr.reg_offs(w)); break;
- case Cfg_long: l4util_out32(value, 0xcfc); break;
- }
- return 0;
-}
-
-#endif
-
-namespace {
-static inline l4_uint32_t
-devfn(unsigned dev, unsigned fn)
-{ return (dev << 16) | fn; }
-
-}
-
-void
-Pci_bridge::scan_bus()
-{
- using namespace Hw::Pci;
-
- int device = 0;
- for (device = 0; device < 32; ++device)
- {
- l4_uint32_t hdr_type;
- cfg_read(num, devfn(device, 0), Pci_dev::C_header_type, &hdr_type, Cfg_byte);
- int funcs = (hdr_type & 0x80) ? 8 : 1;
- for (int function = 0; function < funcs; ++function)
- {
- l4_uint32_t vendor, _class;
- cfg_read(num, devfn(device, function), Pci_dev::C_vendor, &vendor, Cfg_short);
- if (vendor == 0xffff)
- {
- if (function == 0)
- break;
- else
- continue;
- }
-
- cfg_read(num, devfn(device, function), Pci_dev::C_vendor, &vendor, Cfg_long);
- cfg_read(num, devfn(device, function), Pci_dev::C_class_rev, &_class, Cfg_long);
-
- if (function)
- cfg_read(num, devfn(device, function), Pci_dev::C_header_type, &hdr_type, Cfg_byte);
-
- Hw::Device *child = host()->get_child_dev_adr(devfn(device, function), true);
-
- Pci_dev *d;
- if ((_class >> 16) == 0x0604 || (_class >> 16) == 0x0607)
- {
- Pci_pci_bridge_basic *b = 0;
- if ((hdr_type & 0x7f) == 1)
- b = new Pci_pci_bridge(child, this);
- else if((hdr_type & 0x7f) == 2)
- b = new Pci_cardbus_bridge(child, this);
-
- child->set_discover_bus_if(b);
-
- l4_uint32_t busses;
- bool reassign_busses = false;
-
- cfg_read(num, devfn(device, function), Pci_dev::C_primary, &busses, Cfg_long);
-
- if ((busses & 0xff) != num
- || ((busses >> 8) & 0xff) <= num)
- reassign_busses = true;
-
- if (reassign_busses)
- {
- unsigned new_so = subordinate + 1;
- b->pri = num;
- b->num = new_so;
- b->subordinate = b->num;
-
- busses = (busses & 0xff000000)
- | ((l4_uint32_t)(b->pri))
- | ((l4_uint32_t)(b->num) << 8)
- | ((l4_uint32_t)(b->subordinate) << 16);
-
- cfg_write(num, devfn(device, function), Pci_dev::C_primary, busses, Cfg_long);
- increase_subordinate(new_so);
- }
- else
- {
- b->pri = busses & 0xff;
- b->num = (busses >> 8) & 0xff;
- b->subordinate = (busses >> 16) & 0xff;
- }
-
- d = b;
- }
- else
- d = new Pci_dev(child, this);
-
- child->add_feature(d);
- child->add_resource_discoverer(d);
-
- d->vendor_device = vendor;
- d->cls_rev = _class;
- d->hdr_type = hdr_type;
- }
- }
-}
-
-
-class Msi
-{
-public:
- enum Addrs
- {
- Base_hi = 0,
- Base_lo = 0xfee00000,
- };
-
- enum Mode
- {
- Dest_mode_phys = 0 << 2,
- Dest_mode_log = 1 << 2,
- };
-
- enum Redir
- {
- Dest_redir_cpu = 0 << 3,
- Dest_redir_lowprio = 1 << 3,
- };
-
- enum Delivery
- {
- Data_del_fixed = 0 << 8,
- Data_del_lowprio = 1 << 8,
- };
-
- enum Level
- {
- Data_level_deassert = 0 << 14,
- Data_level_assert = 1 << 14,
- };
-
- enum Trigger
- {
- Data_trigger_edge = 0 << 15,
- Data_trigger_level = 1 << 15,
- };
-
- static unsigned data(int vector) { return vector & 0xff; }
-};
-
-l4_uint32_t const *
-Pci_dev::cfg_word(unsigned w) const
-{
- switch (w)
- {
- default: return 0;
- case 0: return &vendor_device;
- case 2: return &cls_rev;
- case 11: return &subsys_ids;
- }
-}
-
-unsigned
-Pci_dev::bus_nr() const
-{ return _bus->num; }
-
-unsigned
-Pci_dev::disable_decoders()
-{
- l4_uint32_t v = 0;
- // disable decoders, and mask IRQs
- cfg_read(C_command, &v, Hw::Pci::Cfg_short);
- cfg_write(C_command, (v & ~3) | (1<<10), Hw::Pci::Cfg_short);
- return v & 0xff;
-}
-
-void
-Pci_dev::restore_decoders(unsigned cmd)
-{
- cfg_write(C_command, cmd, Hw::Pci::Cfg_short);
-}
-
-int
-Pci_dev::discover_bar(int bar)
-{
- using namespace Hw::Pci;
- l4_uint32_t v, x;
-
- _bars[bar] = 0;
- int r = C_bar_0 + bar * 4;
- l4_uint16_t cmd = disable_decoders();
-
- cfg_read(r, &v, Cfg_long);
- cfg_write(r, ~0U, Cfg_long);
- cfg_read(r, &x, Cfg_long);
- cfg_write(r, v, Cfg_long);
-
- restore_decoders(cmd);
-
- if (!x)
- return bar + 1;
-
- unsigned io_flags = (cmd & CC_io) ? 0 : Resource::F_disabled;
- unsigned mem_flags = (cmd & CC_mem) ? 0 : Resource::F_disabled;
-
- io_flags |= Resource::Io_res
- | Resource::F_size_aligned
- | Resource::F_hierarchical;
-
- mem_flags |= Resource::Mmio_res
- | Resource::F_size_aligned
- | Resource::F_hierarchical;
-
- Resource *res = 0;
- if (!(x & 1))
- {
- //printf("%08x: BAR[%d] mmio ... %x\n", adr(), bar, x );
- res = new Resource(mem_flags);
- if ((x & 0x6) == 0x4)
- res->add_flags(Resource::F_width_64bit);
-
- if (x & 0x8)
- res->add_flags(Resource::F_prefetchable);
-
- l4_uint64_t size = x & ~0x7f;
- l4_uint64_t a = v & ~0x7f;
- if (res->is_64bit())
- {
- ++bar;
- r = 0x10 + bar * 4;
- cmd = disable_decoders();
- cfg_read(r, &v, Cfg_long);
- cfg_write(r, ~0U, Cfg_long);
- cfg_read(r, &x, Cfg_long);
- cfg_write(r, v, Cfg_long);
- restore_decoders(cmd);
- a |= l4_uint64_t(v) << 32;
- size |= l4_uint64_t(x) << 32;
- }
-
- for (int s = 7; s < 64; ++s)
- if ((size >> s) & 1)
- {
- size = 1 << s;
- break;
- }
-
- res->start_size(a, size);
-
- // printf("%08x: BAR[%d] mem ...\n", adr(), bar*4 + 10 );
- _bars[bar - res->is_64bit()] = res;
- if (res->is_64bit())
- _bars[bar] = (Resource*)1;
-
- }
- else
- {
- // printf("%08x: BAR[%d] io ...\n", adr(), bar );
- int s;
- for (s = 2; s < 32; ++s)
- if ((x >> s) & 1)
- break;
-
- res = new Resource(io_flags);
-
- _bars[bar] = res;
- res->start_size(v & ~3, 1 << s);
- }
-
- res->validate();
- _host->add_resource(res);
- return bar + 1;
-}
-
-void
-Pci_dev::discover_legacy_ide_resources()
-{
-
- if (!Io_config::cfg->legacy_ide_resources(_host))
- return;
-
- unsigned io_flags = Resource::Io_res
- | Resource::F_size_aligned
- | Resource::F_hierarchical;
-
- // IDE legacy IO interface
- if (cls_rev >> 16 == 0x101 && !(cls_rev & 0x100))
- {
- _host->add_resource(new Resource(io_flags, 0x1f0, 0x1f7));
- _host->add_resource(new Resource(io_flags, 0x3f6, 0x3f6));
- _host->add_resource(new Resource(Resource::Irq_res | Resource::Irq_type_raising_edge, 14, 14));
- }
- if (cls_rev >> 16 == 0x101 && !(cls_rev & 0x400))
- {
- _host->add_resource(new Resource(io_flags, 0x170, 0x177));
- _host->add_resource(new Resource(io_flags, 0x376, 0x376));
- _host->add_resource(new Resource(Resource::Irq_res | Resource::Irq_type_raising_edge, 15, 15));
- }
-}
-
-void
-Pci_dev::quirk_8086_8108()
-{
- using namespace Hw::Pci;
-
- if (!(vendor() == 0x8086 && device() == 0x8108))
- return;
-
- l4_uint32_t v;
-
- // GC - Graphics Control
- cfg_read(0x52, &v, Cfg_short);
-
- unsigned gfx_mem_sz = 0;
-
- // VGA disabled?
- if (v & 2)
- return;
-
- switch ((v >> 4) & 7)
- {
- case 1: gfx_mem_sz = 1 << 20; break;
- case 2: gfx_mem_sz = 4 << 20; break;
- case 3: gfx_mem_sz = 8 << 20; break;
- default: return;
- }
-
- // BSM - Base of Stolen Memory
- cfg_read(0x5c, &v, Cfg_long);
- v &= 0xfff00000;
-
- unsigned flags = Resource::Mmio_res
- | Resource::F_prefetchable
- | Resource::F_fixed_addr
- | Resource::F_fixed_size;
- l4_addr_t end = v + gfx_mem_sz - 1;
-
- _host->add_resource(new Resource(flags, v, end));
- for (Pci_bridge *p = _bus; p;)
- {
- p->host()->add_resource(new Resource_provider(flags, v, end));
- if (Pci_dev *d = dynamic_cast<Pci_dev *>(p))
- p = d->_bus;
- else
- break;
- }
-}
-
-void
-Pci_dev::discover_expansion_rom()
-{
- using namespace Hw::Pci;
-
- if (!Io_config::cfg->expansion_rom(host()))
- return;
-
- l4_uint32_t v, x;
- unsigned rom_register = ((hdr_type & 0x7f) == 0) ? 12 * 4 : 14 * 4;
-
- cfg_read(rom_register, &v, Cfg_long);
-
- if (v == 0xffffffff || v == 0)
- return; // no expansion ROM
-
- cfg_write(rom_register, 0xfffffffe, Cfg_long);
- cfg_read(rom_register, &x, Cfg_long);
- cfg_write(rom_register, v, Cfg_long);
-
- v &= ~0x3ff;
- x &= ~0x3ff;
-
- //printf("ROM %08x: %08x %08x\n", adr(), x, v);
-
- int s;
- for (s = 2; s < 32; ++s)
- if ((x >> s) & 1)
- break;
-
- if (0) // currently we do not add a resource record for ROMs
- {
- unsigned flags = Resource::Mmio_res | Resource::F_size_aligned
- | Resource::F_rom | Resource::F_prefetchable;
- Resource *res = new Resource(flags);
-
- _rom = res;
- res->start_size(v & ~3, 1 << s);
- res->validate();
- _host->add_resource(res);
- }
-}
-
-namespace {
-
-class Msi_res : public Hw::Msi_resource
-{
-public:
- Msi_res(unsigned msi, Pci_bridge *bus, Hw::Pci::Cfg_addr cfg_addr)
- : Msi_resource(msi), _bus(bus), _cfg_addr(cfg_addr)
- {}
-
- int bind(L4::Cap<L4::Irq> irq, unsigned mode);
- int unbind();
-
- void dump(int indent) const
- { Resource::dump("MSI ", indent); }
-
-private:
- Pci_bridge *_bus;
- Hw::Pci::Cfg_addr _cfg_addr;
-};
-
-int
-Msi_res::bind(L4::Cap<L4::Irq> irq, unsigned mode)
-{
- using namespace Hw::Pci;
-
- int err = Msi_resource::bind(irq, mode);
- if (err < 0)
- return err;
-
- l4_umword_t msg = 0;
- int e2 = l4_error(system_icu()->icu->msi_info(pin(), &msg));
- if (e2 < 0)
- {
- d_printf(DBG_ERR, "ERROR: could not get MSI message (pin=%x)\n", pin());
- return e2;
- }
-
- // MSI capability
- l4_uint32_t ctl;
- int msg_offs = 8;
-
- _bus->cfg_read(_cfg_addr + 2, &ctl, Cfg_short);
- if (ctl & (1 << 7))
- msg_offs = 12;
-
- _bus->cfg_write(_cfg_addr + 4, Msi::Base_lo | Msi::Dest_mode_phys | Msi::Dest_redir_cpu, Cfg_long);
-
- if (ctl & (1 << 7))
- _bus->cfg_write(_cfg_addr + 8, Msi::Base_hi, Cfg_long);
-
- _bus->cfg_write(_cfg_addr + msg_offs, Msi::Data_level_assert | Msi::Data_trigger_edge | Msi::Data_del_fixed | Msi::data(msg), Cfg_short);
-
- _bus->cfg_write(_cfg_addr + 2, ctl | 1, Cfg_short);
-
- d_printf(DBG_DEBUG2, "MSI: enable kernel PIN=%x hwpci=%02x:%02x.%x: reg=%03x msg=%lx\n",
- pin(), _cfg_addr.bus(), _cfg_addr.dev(), _cfg_addr.fn(),
- _cfg_addr.reg(), msg);
-
- return err;
-}
-
-int
-Msi_res::unbind()
-{
- using namespace Hw::Pci;
- // disable MSI
- l4_uint32_t ctl;
- _bus->cfg_read(_cfg_addr + 2, &ctl, Cfg_short);
- _bus->cfg_write(_cfg_addr + 2, ctl & ~1, Cfg_short);
-
- return Msi_resource::unbind();
-}
-
-}
-
-void
-Pci_dev::discover_pci_caps()
-{
- using namespace Hw::Pci;
-
- {
- l4_uint32_t status;
- cfg_read(C_status, &status, Cfg_short);
- if (!(status & CS_cap_list))
- return;
- }
-
- l4_uint32_t cap_ptr;
- cfg_read(C_capability_ptr, &cap_ptr, Cfg_byte);
- cap_ptr &= ~0x3;
- for (; cap_ptr; cfg_read(cap_ptr + 1, &cap_ptr, Cfg_byte), cap_ptr &= ~0x3)
- {
- l4_uint32_t id;
- cfg_read(cap_ptr, &id, Cfg_byte);
- // printf(" PCI-cap: %x %s %s\n", id, Io_config::cfg->transparent_msi(host()) ? "yes" : "no", system_icu()->info.supports_msi() ? "yes" : "no" );
- if (id == 0x05 && Io_config::cfg->transparent_msi(host())
- && system_icu()->info.supports_msi())
- {
- // MSI capability
-
- unsigned msi = _last_msi++;
- if (msi >= system_icu()->info.nr_msis)
- {
- d_printf(DBG_WARN, "WARNING: run out of MSI vectors, use normal IRQ\n");
- continue;
- }
-
- for (Resource_list::const_iterator i = host()->resources()->begin();
- i != host()->resources()->end(); ++i)
- {
- if ((*i)->type() == Resource::Irq_res)
- {
- (*i)->set_empty();
- (*i)->add_flags(Resource::F_disabled);
- }
- }
-
- d_printf(DBG_DEBUG, "Use MSI PCI device %02x:%02x:%x: pin=%x\n",
- bus()->num, host()->adr() >> 16, host()->adr() & 0xff, msi);
-
- Resource *res = new Msi_res(msi, bus(), cfg_addr(cap_ptr));
- flags |= F_msi;
- _host->add_resource(res);
- }
- }
-}
-
-void
-Pci_dev::discover_resources(Hw::Device *host)
-{
- using namespace Hw::Pci;
-
- // printf("survey ... %x.%x\n", dynamic_cast<Pci_bridge*>(parent())->num, adr());
- l4_uint32_t v;
- cfg_read(C_subsys_vendor, &v, Cfg_long);
- subsys_ids = v;
- cfg_read(C_irq_pin, &v, Cfg_byte);
- irq_pin = v;
-
- if (irq_pin)
- {
- Resource * r = new Resource(Resource::Irq_res | Resource::F_relative
- | Resource::F_hierarchical,
- irq_pin - 1, irq_pin - 1);
- r->dump(0);
- host->add_resource(r); //new Resource(Resource::Irq_res | Resource::F_relative
-// | Resource::F_hierarchical,
-// irq_pin - 1, irq_pin - 1));
- }
-
- cfg_read(C_command, &v, Cfg_short);
-
- int bars = ((hdr_type & 0x7f) == 0) ? 6 : 2;
-
- discover_legacy_ide_resources();
-
- quirk_8086_8108();
-
- for (int bar = 0; bar < bars;)
- bar = discover_bar(bar);
-
- discover_expansion_rom();
- discover_pci_caps();
-}
-
-void
-Pci_dev::setup_resources(Hw::Device *)
-{
- using namespace Hw::Pci;
-
- for (unsigned i = 0; i < sizeof(_bars)/sizeof(_bars[0]); ++i)
- {
- Resource *r = bar(i);
- if (!r || r->type() == Resource::Io_res)
- continue;
-
- if (r->empty())
- continue;
-
- int reg = 0x10 + i * 4;
- l4_uint64_t s = r->start();
- l4_uint16_t cmd = disable_decoders();
- cfg_write(reg, s, Cfg_long);
- if (r->is_64bit())
- {
- cfg_write(reg + 4, s >> 32, Cfg_long);
- ++i;
- }
- restore_decoders(cmd);
-
-
- l4_uint32_t v;
- cfg_read(reg, &v, Cfg_long);
- if (l4_uint32_t(v & ~0x7f) != l4_uint32_t(s & 0xffffffff))
- d_printf(DBG_ERR, "ERROR: could not set PCI BAR %d\n", i);
-
- // printf("%08x: set BAR[%d] to %08x\n", adr(), i, v);
- }
-}
-
-
-bool
-Pci_dev::match_cid(cxx::String const &_cid) const
-{
- cxx::String const prefix("PCI/");
- cxx::String cid(_cid);
- if (!cid.starts_with(prefix))
- return false;
-
- cid = cid.substr(prefix.len());
- cxx::String::Index n;
- for (; cid.len() > 0; cid = cid.substr(n + 1))
- {
- n = cid.find("&");
- cxx::String tok = cid.head(n);
- if (tok.empty())
- continue;
-
- if (tok.starts_with("CC_"))
- {
- tok = tok.substr(3);
- if (tok.len() < 2)
- return false;
-
- l4_uint32_t _csr;
- int l = tok.from_hex(&_csr);
- if (l < 0 || l > 6 || l % 2)
- return false;
-
- if ((cls_rev >> (8 + (6-l) * 4)) == _csr)
- continue;
- else
- return false;
- }
- else if (tok.starts_with("REV_"))
- {
- tok = tok.substr(4);
- unsigned char r;
- if (tok.len() != 2 || tok.from_hex(&r) != 2)
- return false;
-
- if (r != (cls_rev & 0xff))
- return false;
- }
- else if (tok.starts_with("VEN_"))
- {
- tok = tok.substr(4);
- l4_uint32_t v;
- if (tok.len() != 4 || tok.from_hex(&v) != 4)
- return false;
-
- if ((vendor_device & 0xffff) != v)
- return false;
- }
- else if (tok.starts_with("DEV_"))
- {
- tok = tok.substr(4);
- l4_uint32_t d;
- if (tok.len() != 4 || tok.from_hex(&d) != 4)
- return false;
-
- if (((vendor_device >> 16) & 0xffff) != d)
- return false;
- }
- else if (tok.starts_with("SUBSYS_"))
- {
- l4_uint32_t s;
- tok = tok.substr(7);
- if (tok.len() != 8 || tok.from_hex(&s) != 8)
- return false;
- if (subsys_ids != s)
- return false;
- }
- else
- return false;
- }
-
- return true;
-}
-
-void
-Pci_pci_bridge::setup_resources(Hw::Device *host)
-{
- using namespace Hw::Pci;
-
- Pci_dev::setup_resources(host);
-
- if (!mmio->empty() && mmio->valid())
- {
- l4_uint32_t v = (mmio->start() >> 16) & 0xfff0;
- v |= mmio->end() & 0xfff00000;
- cfg_write(0x20, v, Cfg_long);
- // printf("%08x: set mmio to %08x\n", adr(), v);
- l4_uint32_t r;
- cfg_read(0x20, &r, Cfg_long);
- // printf("%08x: mmio = %08x\n", adr(), r);
- cfg_read(0x04, &r, Cfg_short);
- r |= 3;
- cfg_write(0x4, r, Cfg_short);
- }
-
- if (!pref_mmio->empty() && pref_mmio->valid())
- {
- l4_uint32_t v = (pref_mmio->start() >> 16) & 0xfff0;
- v |= pref_mmio->end() & 0xfff00000;
- cfg_write(0x24, v, Cfg_long);
- // printf("%08x: set pref mmio to %08x\n", adr(), v);
- }
-}
-
-void
-Pci_pci_bridge::discover_resources(Hw::Device *host)
-{
- using namespace Hw::Pci;
-
- l4_uint32_t v;
- l4_uint64_t s, e;
-
- cfg_read(C_mem_base, &v, Cfg_long);
- s = (v & 0xfff0) << 16;
- e = (v & 0xfff00000) | 0xfffff;
-
- Resource *r = new Resource_provider(Resource::Mmio_res);
- r->alignment(0xfffff);
- if (s < e)
- r->start_end(s, e);
- else
- r->set_empty();
-
- // printf("%08x: mmio = %08x\n", adr(), v);
- mmio = r;
- mmio->validate();
- _host->add_resource(mmio);
-
- r = new Resource_provider(Resource::Mmio_res | Resource::F_prefetchable);
- cfg_read(C_pref_mem_base, &v, Cfg_long);
- s = (v & 0xfff0) << 16;
- e = (v & 0xfff00000) | 0xfffff;
-
- if ((v & 0x0f) == 1)
- {
- r->add_flags(Resource::F_width_64bit);
- cfg_read(C_pref_mem_base_hi, &v, Cfg_long);
- s |= l4_uint64_t(v) << 32;
- cfg_read(C_pref_mem_limit_hi, &v, Cfg_long);
- e |= l4_uint64_t(v) << 32;
- }
-
- r->alignment(0xfffff);
- if (s < e)
- r->start_end(s, e);
- else
- r->set_empty();
-
- pref_mmio = r;
- r->validate();
- _host->add_resource(r);
-
- cfg_read(C_io_base, &v, Cfg_short);
- s = (v & 0xf0) << 8;
- e = (v & 0xf000) | 0xfff;
-
- r = new Resource_provider(Resource::Io_res);
- r->alignment(0xfff);
- if (s < e)
- r->start_end(s, e);
- else
- r->set_empty();
- io = r;
- r->validate();
- _host->add_resource(r);
-
- Pci_dev::discover_resources(host);
-}
-
-
-void
-Pci_root_bridge::discover_resources(Hw::Device *)
-{}
-
-
-
-
-static const char * const pci_classes[] =
- { "unknown", "mass storage contoller", "network controller",
- "display controller", "multimedia device", "memory controller",
- "bridge device", "simple communication controller",
- "system peripheral", "input device", "docking station",
- "processor", "serial bus controller", "wireless controller",
- "intelligent I/O controller", "satellite communication controller",
- "encryption/decryption controller",
- "data aquisition/signal processing controller" };
-
-static char const * const pci_bridges[] =
-{ "Host/PCI Bridge", "ISA Bridge", "EISA Bridge", "Micro Channel Bridge",
- "PCI Bridge", "PCMCIA Bridge", "NuBus Bridge", "CardBus Bridge" };
-
-
-#if 0
-static void
-dump_res_rec(Resource_list const *r, int indent)
-{
- for (Resource_list::iterator i = r->begin(); i!= r->end(); ++i)
- if (*i)
- {
- i->dump(indent + 2);
- //dump_res_rec(i->child(), indent + 2);
- }
-}
-#endif
-
-void
-Pci_dev::dump(int indent) const
-{
- char const *classname = "";
-
- if (cls_rev >> 24 < sizeof(pci_classes)/sizeof(pci_classes[0]))
- classname = pci_classes[cls_rev >> 24];
-
- if ((cls_rev >> 24) == 0x06)
- {
- unsigned sc = (cls_rev >> 16) & 0xff;
- if (sc < sizeof(pci_bridges)/sizeof(pci_bridges[0]))
- classname = pci_bridges[sc];
- }
-
- printf("%*.s%04x:%02x:%02x.%x: %s [%d]\n", indent, " ",
- 0, (int)_bus->num, _host->adr() >> 16, _host->adr() & 0xffff,
- classname, (int)hdr_type);
-
- char buf[130];
- printf("%*.s 0x%04x 0x%04x\n", indent, " ", vendor(), device());
- libpciids_name_device(buf, sizeof(buf), vendor(), device());
- printf("%*.s %s\n", indent, " ", buf);
-#if 0
- if (verbose_lvl)
- dump_res_rec(resources(), 0);
-#endif
-}
-
-void
-Pci_bridge::dump(int) const
-{
-#if 0
- "bridge %04x:%02x:%02x.%x\n",
- b->num, 0, b->parent() ? (int)static_cast<Pci_bridge*>(b->parent())->num : 0,
- b->adr() >> 16, b->adr() & 0xffff);
-#endif
-#if 0
- //dump_res_rec(resources(), 0);
-
- for (iterator c = begin(0); c != end(); ++c)
- c->dump();
-#endif
-};
-
-
-
-void
-Pci_cardbus_bridge::discover_resources(Hw::Device *host)
-{
- using namespace Hw::Pci;
- l4_uint32_t v;
- cfg_read(C_subsys_vendor, &v, Cfg_long);
- subsys_ids = v;
-
- Resource *r = new Resource_provider(Resource::Mmio_res);
- cfg_read(C_cb_mem_base_0, &v, Cfg_long);
- r->start(v);
- cfg_read(C_cb_mem_limit_0, &v, Cfg_long);
- r->end(v);
- if (!r->end())
- r->set_empty();
- r->validate();
- host->add_resource(r);
-
- r = new Resource_provider(Resource::Mmio_res);
- cfg_read(C_cb_mem_base_1, &v, Cfg_long);
- r->start(v);
- cfg_read(C_cb_mem_limit_1, &v, Cfg_long);
- r->end(v);
- if (!r->end())
- r->set_empty();
- r->validate();
- host->add_resource(r);
-
- r = new Resource_provider(Resource::Io_res);
- cfg_read(C_cb_io_base_0, &v, Cfg_long);
- r->start(v);
- cfg_read(C_cb_io_limit_0, &v, Cfg_long);
- r->end(v);
- if (!r->end())
- r->set_empty();
- r->validate();
- host->add_resource(r);
-
- r = new Resource_provider(Resource::Io_res);
- cfg_read(C_cb_io_base_1, &v, Cfg_long);
- r->start(v);
- cfg_read(C_cb_io_limit_1, &v, Cfg_long);
- r->end(v);
- if (!r->end())
- r->set_empty();
- r->validate();
- host->add_resource(r);
-}
-
-void
-Pci_irq_router::dump(int indent) const
-{
- printf("%*sPCI IRQ ROUTER: %s (%p)\n", indent, "", typeid(*this).name(),
- this);
-}
-
-bool
-Pci_pci_bridge_irq_router_rs::request(Resource *parent, Device *pdev,
- Resource *child, Device *cdev)
-{
- bool res = false;
-
- Hw::Device *cd = dynamic_cast<Hw::Device*>(cdev);
-
- if (!cd)
- return res;
-
- if (pdev->parent())
- {
- child->start((child->start() + (cd->adr() >> 16)) & 3);
- res = pdev->parent()->request_child_resource(child, pdev);
- if (res)
- child->parent(parent);
- }
-
- return res;
-}
-
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#include "debug.h"
-#include "hw_device.h"
-#include "pci.h"
-#include "main.h"
-
-namespace {
-
-inline
-l4_uint32_t
-pci_conf_addr0(l4_uint32_t bus, l4_uint32_t dev,
- l4_uint32_t fn, l4_uint32_t reg)
-{ return (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3); }
-
-class Pci_iomem_root_bridge : public Pci_root_bridge, public Hw::Device
-{
-public:
- typedef Hw::Pci::Cfg_width Cfg_width;
-
- explicit Pci_iomem_root_bridge(unsigned bus_nr = 0)
- : Pci_root_bridge(bus_nr, this), _iobase_virt(0), _iobase_phys(~0UL),
- _dev_start(~0UL), _dev_end(~0UL), _iosize(0)
- {
- set_discover_bus_if(this);
- }
-
- int cfg_read(Cfg_addr addr, l4_uint32_t *value, Cfg_width);
- int cfg_write(Cfg_addr addr, l4_uint32_t value, Cfg_width);
-
- void scan_bus();
-
- void init();
-
- int set_property(cxx::String const &prop, Prop_val const &val);
- template< typename T>
- int getval(const char *s, cxx::String const &prop,
- Prop_val const &val, T *rval);
- int int_map(int i) const { return _int_map[i]; }
-
-private:
- l4_addr_t _iobase_virt, _iobase_phys, _dev_start, _dev_end;
- int _int_map[4];
- l4_size_t _iosize;
-};
-
-// Irq router that maps INTA-D to GSI
-class Irq_router_rs : public Resource_space
-{
-public:
- bool request(Resource *parent, Device *, Resource *child, Device *cdev);
- bool alloc(Resource *, Device *, Resource *, Device *, bool)
- { return false; }
-};
-
-void
-Pci_iomem_root_bridge::init()
-{
- if (_iobase_phys == ~0UL)
- {
- d_printf(DBG_ERR, "ERROR: Pci_root_bridge: 'iobase' not set.\n");
- return;
- }
-
- if (_iosize == 0U)
- {
- d_printf(DBG_ERR, "ERROR: Pci_root_bridge: 'iosize' not set.\n");
- return;
- }
-
- if (_dev_start == ~0UL || _dev_end == ~0UL)
- {
- d_printf(DBG_ERR, "ERROR: Pci_root_bridge: 'dev_start' and/or 'dev_end' not set.\n");
- return;
- }
-
- _iobase_virt = res_map_iomem(_iobase_phys, _iosize);
- if (!_iobase_virt)
- return;
-
- add_resource(new Resource(Resource::Mmio_res
- | Resource::F_fixed_size
- | Resource::F_fixed_addr,
- _iobase_phys,
- _iobase_phys + _iosize - 1));
-
- Resource *r = new Resource_provider(Resource::Mmio_res
- | Resource::F_fixed_size
- | Resource::F_fixed_addr);
- r->alignment(0xfffff);
- r->start_end(_dev_start, _dev_end);
- add_resource(r);
-
- r = new Resource_provider(Resource::Io_res
- | Resource::F_fixed_size
- | Resource::F_fixed_addr);
- r->start_end(0, 0xffff);
- add_resource(r);
-
- add_resource(new Pci_irq_router_res<Irq_router_rs>());
-
- Hw::Device::init();
-}
-
-void
-Pci_iomem_root_bridge::scan_bus()
-{
- if (!_iobase_virt)
- return;
- Pci_root_bridge::scan_bus();
-}
-
-int
-Pci_iomem_root_bridge::cfg_read(Cfg_addr addr, l4_uint32_t *value, Cfg_width w)
-{
- using namespace Hw;
-
- if (!_iobase_virt)
- return -1;
-
- l4_uint32_t a = _iobase_virt + addr.to_compat_addr();
- switch (w)
- {
- case Pci::Cfg_byte: *value = *(volatile l4_uint8_t *)a; break;
- case Pci::Cfg_short: *value = *(volatile l4_uint16_t *)a; break;
- case Pci::Cfg_long: *value = *(volatile l4_uint32_t *)a; break;
- }
-
- d_printf(DBG_ALL, "Pci_iomem_root_bridge::cfg_read(%x, %x, %x, %x, %x, %d)\n",
- addr.bus(), addr.dev(), addr.fn(), addr.reg(), *value, w);
-
- return 0;
-}
-
-int
-Pci_iomem_root_bridge::cfg_write(Cfg_addr addr, l4_uint32_t value, Cfg_width w)
-{
- using namespace Hw;
-
- if (!_iobase_virt)
- return -1;
-
- d_printf(DBG_ALL, "Pci_iomem_root_bridge::cfg_write(%x, %x, %x, %x, %x, %d)\n",
- addr.bus(), addr.dev(), addr.fn(), addr.reg(), value, w);
-
- l4_uint32_t a = _iobase_virt + addr.to_compat_addr();
- switch (w)
- {
- case Pci::Cfg_byte: *(volatile l4_uint8_t *)a = value; break;
- case Pci::Cfg_short: *(volatile l4_uint16_t *)a = value; break;
- case Pci::Cfg_long: *(volatile l4_uint32_t *)a = value; break;
- }
- return 0;
-}
-
-template< typename T>
-int
-Pci_iomem_root_bridge::getval(const char *s, cxx::String const &prop,
- Prop_val const &val, T *rval)
-{
- if (prop == s)
- {
- if (val.type != Prop_val::Int)
- return -E_inval;
-
- *rval = val.val.integer;
- return E_ok;
- }
- return -E_no_prop;
-}
-
-int
-Pci_iomem_root_bridge::set_property(cxx::String const &prop, Prop_val const &val)
-{
- int r;
-
- if ((r = getval("iobase", prop, val, &_iobase_phys)) != -E_no_prop)
- return r;
- else if ((r = getval("iosize", prop, val, &_iosize)) != -E_no_prop)
- return r;
- else if ((r = getval("dev_start", prop, val, &_dev_start)) != -E_no_prop)
- return r;
- else if ((r = getval("dev_end", prop, val, &_dev_end)) != -E_no_prop)
- return r;
- else if ((r = getval("int_a", prop, val, &_int_map[0])) != -E_no_prop)
- return r;
- else if ((r = getval("int_b", prop, val, &_int_map[1])) != -E_no_prop)
- return r;
- else if ((r = getval("int_c", prop, val, &_int_map[2])) != -E_no_prop)
- return r;
- else if ((r = getval("int_d", prop, val, &_int_map[3])) != -E_no_prop)
- return r;
-
- return Hw::Device::set_property(prop, val);
-}
-
-static Hw::Device_factory_t<Pci_iomem_root_bridge>
- __hw_pci_root_bridge_factory("Pci_iomem_root_bridge");
-
-bool Irq_router_rs::request(Resource *parent, Device *pdev,
- Resource *child, Device *cdev)
-{
- Hw::Device *cd = dynamic_cast<Hw::Device*>(cdev);
- if (!cd)
- return false;
-
- if (child->start() > 3)
- return false;
-
- int i = (child->start() + (cd->adr() >> 16)) & 3;
-
- Pci_iomem_root_bridge *pd = dynamic_cast<Pci_iomem_root_bridge *>(pdev);
- if (!pd)
- return false;
-
-
- child->del_flags(Resource::F_relative);
- child->start(pd->int_map(i));
- child->del_flags(Resource::Irq_type_mask);
- child->add_flags(Resource::Irq_type_level_low);
-
- child->parent(parent);
-
- return true;
-}
-}
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#include <l4/re/protocols>
-
-#include <l4/cxx/ipc_server>
-
-#include <l4/re/env>
-#include <l4/re/namespace>
-#include <l4/re/dataspace-sys.h>
-
-#include <l4/re/error_helper>
-
-#include <l4/vbus/vbus_types.h>
-#include <l4/vbus/vdevice-ops.h>
-
-#include <cstdio>
-
-#include "debug.h"
-#include "hw_msi.h"
-#include "vbus.h"
-#include "vmsi.h"
-#include "vicu.h"
-#include "server.h"
-#include "res.h"
-#include "cfg.h"
-#include "vbus_factory.h"
-
-Vi::System_bus::Root_resource_factory::Factory_list
- Vi::System_bus::Root_resource_factory::_factories;
-
-namespace {
-
-class Root_irq_rs : public Resource_space
-{
-private:
- Vi::System_bus *_bus;
- Vi::Sw_icu *_icu;
-
-public:
- Root_irq_rs(Vi::System_bus *bus)
- : Resource_space(), _bus(bus), _icu(new Vi::Sw_icu())
- {
- _bus->add_child(_icu);
- _bus->sw_icu(_icu);
- }
-
- bool request(Resource *parent, Device *, Resource *child, Device *)
- {
- // printf("VBUS: IRQ resource request: "); child->dump();
- if (!parent)
- return false;
-
- if (!_icu)
- {
- _icu = new Vi::Sw_icu();
- _bus->add_child(_icu);
- _bus->sw_icu(_icu);
- }
-
- d_printf(DBG_DEBUG2, "Add IRQ resources to vbus: ");
- if (dlevel(DBG_DEBUG2))
- child->dump();
-
- _icu->add_irqs(child);
- _bus->resource_set()->insert(child);
-
- return true;
- };
-
- bool alloc(Resource *parent, Device *, Resource *child, Device *, bool)
- {
- d_printf(DBG_DEBUG2, "Allocate virtual IRQ resource ...\n");
- if (dlevel(DBG_DEBUG2))
- child->dump();
-
- Vi::Msi_resource *msi = dynamic_cast<Vi::Msi_resource*>(child);
- if (!msi || !parent)
- return false;
-
- d_printf(DBG_DEBUG2, " Allocate Virtual MSI...\n");
-
- if (!_icu)
- {
- _icu = new Vi::Sw_icu();
- _bus->add_child(_icu);
- }
-
- int nr = _icu->alloc_irq(msi->flags(), msi->hw_msi());
- if (nr < 0)
- {
- d_printf(DBG_ERR, "ERROR: cannot allocate MSI resource\n");
- return false;
- }
-
- msi->start_end(nr, nr);
- msi->del_flags(Resource::F_disabled);
-
- if (dlevel(DBG_DEBUG2))
- {
- msi->dump(4);
- msi->hw_msi()->dump(4);
- }
-
- _bus->resource_set()->insert(msi);
- return true;
- }
-
- ~Root_irq_rs() {}
-};
-
-class Root_x_rs : public Resource_space
-{
-private:
- Vi::System_bus *_bus;
-
-public:
- Root_x_rs(Vi::System_bus *bus) : Resource_space(), _bus(bus)
- {}
-
- bool request(Resource *parent, Device *, Resource *child, Device *)
- {
- //printf("VBUS: X resource request: "); child->dump();
- if (!parent)
- return false;
-
-
- _bus->resource_set()->insert(child);
- return true;
- }
-
- bool alloc(Resource *, Device *, Resource *, Device *, bool)
- { return false; }
-
- ~Root_x_rs() {}
-};
-}
-
-
-
-namespace Vi {
-
-bool
-System_bus::resource_allocated(Resource const *r) const
-{
- Resource_set::const_iterator i = _resources.find(const_cast<Resource*>(r));
- if (i == _resources.end())
- return false;
-
- if ((*i)->start() <= r->start()
- && (*i)->end() >= r->end())
- return true;
-
- return false;
-}
-
-
-System_bus::System_bus() : _sw_icu(0)
-{
- add_feature(this);
- add_resource(new Root_resource(Resource::Irq_res, new Root_irq_rs(this)));
- Resource_space *x = new Root_x_rs(this);
- add_resource(new Root_resource(Resource::Mmio_res, x));
- add_resource(new Root_resource(Resource::Mmio_res | Resource::F_prefetchable, x));
- add_resource(new Root_resource(Resource::Io_res, x));
- typedef Root_resource_factory RF;
- for (RF::Factory_list::Const_iterator i = RF::_factories.begin();
- i != RF::_factories.end();
- ++i)
- add_resource((*i)->create(this));
-}
-
-System_bus::~System_bus()
-{
- registry->unregister_obj(this);
- // FIXME: must delete all devices
-}
-
-
-void
-System_bus::dump_resources() const
-{
- for (Resource_set::const_iterator i = _resources.begin(); i != _resources.end(); ++i)
- (*i)->dump();
-}
-
-int
-System_bus::request_resource(L4::Ipc::Iostream &ios)
-{
- l4vbus_resource_t res;
- ios.get(res);
-
- Resource ires(res.type, res.start, res.end);
- if (dlevel(DBG_DEBUG2))
- {
- printf("request resource: ");
- ires.dump();
- puts("");
- }
-
- Resource_set::const_iterator i = _resources.find(&ires);
-#if 0
- for (Resource_set::Const_iterator m = _resources.begin(); m != _resources.end(); ++m)
- {
- m->dump();
- puts("");
- }
-#endif
-
- if (i == _resources.end() || !(*i)->contains(ires))
- return -L4_ENOENT;
-
-#if 0
- if (Io_config::cfg->verbose() > 1)
- {
- printf(" found resource: ");
- i->dump();
- puts("");
- }
-#endif
-
- if (res.type == L4VBUS_RESOURCE_PORT)
- {
- l4_uint64_t sz = res.end + 1 - res.start;
-
- int szl2 = 0;
- while ((1UL << szl2) < sz)
- ++szl2;
-
- if ((1UL << szl2) > sz)
- --szl2;
-
- ios << L4::Ipc::Snd_fpage::io(res.start, szl2, L4_FPAGE_RWX);
- return L4_EOK;
- }
-
-
- return -L4_ENOENT;
-}
-
-int
-System_bus::request_iomem(L4::Ipc::Iostream &ios)
-{
- L4::Opcode op;
- ios >> op;
- switch (op)
- {
- case L4Re::Dataspace_::Map:
- {
- l4_addr_t offset, spot;
- unsigned long flags;
- ios >> offset >> spot >> flags;
-
-// printf("map iomem: %lx...\n", offset);
- Resource pivot(L4VBUS_RESOURCE_MEM, offset, offset);
- Resource_set::iterator r = _resources.find(&pivot);
-
- if (r == _resources.end())
- return -L4_ERANGE;
-
- offset = l4_trunc_page(offset);
-
- l4_addr_t st = l4_trunc_page((*r)->start());
- l4_addr_t adr = (*r)->map_iomem();
-
- if (!adr)
- return -L4_ENOMEM;
-
- adr = l4_trunc_page(adr);
-
- l4_addr_t addr = offset - st + adr;
- unsigned char order
- = l4_fpage_max_order(L4_PAGESHIFT,
- addr, addr, addr + (*r)->size(), spot);
-
- // we also might want to do WB instead of UNCACHED...
- ios << L4::Ipc::Snd_fpage::mem(l4_trunc_size(addr, order), order,
- L4_FPAGE_RWX, l4_trunc_page(spot),
- L4::Ipc::Snd_fpage::Map,
- L4::Ipc::Snd_fpage::Uncached);
- return L4_EOK;
- }
- }
- return -L4_ENOSYS;
-};
-
-int
-System_bus::dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios)
-{
- l4_msgtag_t tag;
- ios >> tag;
-
- if (tag.label() == 0)
- {
- l4vbus_device_handle_t devid;
- l4_uint32_t func;
- ios >> devid >> func;
- Device *dev = get_dev_by_id(devid);
- if (!dev)
- return -L4_ENODEV;
- return dev->vdevice_dispatch(obj, func, ios);
- }
-
- if (tag.label() == L4Re::Protocol::Dataspace)
- return request_iomem(ios);
-
- return -L4_EBADPROTO;
-
-}
-
-int
-System_bus::dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- switch (func)
- {
- case L4vbus_vbus_request_resource:
- return request_resource(ios);
- default:
- return -L4_ENOSYS;
- }
-}
-
-
-static Dev_factory_t<System_bus> __sb_root_factory("System_bus");
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#pragma once
-
-#include <l4/cxx/avl_set>
-#include <l4/cxx/ipc_server>
-#include <l4/cxx/hlist>
-
-#include <l4/vbus/vbus_types.h>
-
-#include "vdevice.h"
-#include "device.h"
-
-namespace Vi {
-class Sw_icu;
-
-class System_bus : public Device, public Dev_feature, public L4::Server_object
-{
-public:
- class Root_resource_factory : public cxx::H_list_item
- {
- public:
- virtual Root_resource *create(System_bus *bus) const = 0;
- Root_resource_factory()
- { _factories.push_front(this); }
-
- typedef cxx::H_list<Root_resource_factory> Factory_list;
- static Factory_list _factories;
- };
-
- template< unsigned TYPE, typename RS >
- class Root_resource_factory_t : public Root_resource_factory
- {
- public:
- Root_resource *create(System_bus *bus) const
- {
- return new Root_resource(TYPE, new RS(bus));
- }
- };
-
- System_bus();
- ~System_bus();
-
- // dispatch for the server object
- int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
- int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
- bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
-
-private:
- int request_resource(L4::Ipc::Iostream &ios);
- int request_iomem(L4::Ipc::Iostream &ios);
-
-public:
- bool resource_allocated(Resource const *) const;
-
- void dump_resources() const;
-
-private:
- struct Res_cmp
- {
- bool operator () (Resource const *a, Resource const *b) const
- {
- if (a->type() == b->type())
- return a->lt_compare(b);
- return a->type() < b->type();
- }
- };
- //typedef std::set<Resource*, Res_cmp> Resource_set;
-
-public:
- typedef cxx::Avl_set<Resource*, Res_cmp> Resource_set;
-
- Resource_set const *resource_set() const { return &_resources; }
- Resource_set *resource_set() { return &_resources; }
-
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
- Sw_icu *sw_icu() const { return _sw_icu; }
-
- void sw_icu(Sw_icu *icu) { _sw_icu = icu; }
-
-private:
- Resource_set _resources;
- Device *_host;
- Sw_icu *_sw_icu;
-
-};
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#include "debug.h"
-#include "vbus_factory.h"
-
-namespace Vi {
-
-cxx::H_list<Dev_factory> Dev_factory::_for_type(true);
-
-Dev_factory::Dev_factory(std::type_info const *type) : _type(type)
-{
- if (!type)
- return;
-
- printf("Dev_factory: register factory for %s\n", type->name());
- Iterator i = _for_type.end();
- for (Iterator c = _for_type.begin(); c != _for_type.end(); ++c)
- {
- void *x = 0;
- // use the compiler catch logic to figure out if TYPE
- // is a base class of c->_type, if it is we must put
- // this behind c in the list.
- if (type->__do_catch(c->_type, &x, 0))
- i = c;
- }
-
- _for_type.insert(this, i);
-}
-
-Device *
-Dev_factory::create(std::string const &_class)
-{
- Name_map &m = name_map();
- Name_map::iterator i = m.find(_class);
- if (i == m.end())
- {
- d_printf(DBG_WARN, "WARNING: cannot create virtual device: '%s'\n",
- _class.c_str());
- return 0;
- }
-
- return i->second->vcreate();
-}
-
-Device *
-Dev_factory::create(Hw::Device *f, bool warn)
-{
- if (!f)
- return 0;
-
- for (Iterator fa = _for_type.begin(); fa != _for_type.end(); ++fa)
- if (Device *d = fa->vcreate(f))
- return d;
-
- if (warn)
- d_printf(DBG_WARN, "WARNING: cannot fabricate buddy object for '%s'\n",
- typeid(*f).name());
- return 0;
-}
-
-}
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#pragma once
-
-#include "main.h"
-#include "debug.h"
-
-#include <l4/cxx/avl_map>
-#include <l4/cxx/hlist>
-#include <string>
-#include <typeinfo>
-
-#include "hw_device.h"
-#include "vdevice.h"
-
-namespace Vi {
-
-template< typename VI, typename HW >
-class Generic_type_factory
-: public cxx::H_list_item
-{
-private:
- typedef Generic_type_factory<VI, HW> Self;
- typedef cxx::H_list<Self> List;
- typedef typename List::Iterator Iterator;
-
- static List _for_type;
-
-public:
- virtual VI *vcreate(HW *f) = 0;
- virtual ~Generic_type_factory() {}
-
- static VI *create(HW *f, bool warn = true);
-
-protected:
- explicit Generic_type_factory(std::type_info const *type);
-
-private:
- std::type_info const *_type;
-};
-
-template< typename VI, typename HW >
-cxx::H_list<Generic_type_factory<VI,HW> > Generic_type_factory<VI,HW>::_for_type(true);
-
-typedef Generic_type_factory<Dev_feature, Hw::Dev_feature> Feature_factory;
-typedef Generic_type_factory<Resource, Resource> Resource_factory;
-
-class Dev_factory : public cxx::H_list_item
-{
-public:
- virtual Device *vcreate() = 0;
- virtual Device *vcreate(Hw::Device *f) = 0;
-
- typedef cxx::Avl_map<std::string, Dev_factory *> Name_map;
- typedef cxx::H_list<Dev_factory> List;
- typedef List::Iterator Iterator;
-
- static List _for_type;
- std::type_info const *_type;
-
-protected:
- explicit Dev_factory(std::type_info const *type);
-
- static Name_map &name_map()
- {
- static Name_map _name_map;
- return _name_map;
- }
-
-public:
- static Device *create(std::string const &_class);
- static Device *create(Hw::Device *f, bool warn = true);
-
-private:
- Dev_factory(Dev_factory const &);
- void operator = (Dev_factory const &);
-};
-
-
-template< typename VI, typename HW_BASE, typename HW, typename BASE >
-class Generic_factory_t : public BASE
-
-{
-public:
-
- Generic_factory_t() : BASE(&typeid(HW)) {}
-
- VI *vcreate(HW_BASE *dev)
- {
-#if 0
- if (dev->ref_count())
- printf("WARNING: device '%s' already assigned to an other virtual bus.\n",
- dev->name());
-#endif
-
- VI *d = 0;
- if (HW* h = dynamic_cast<HW*>(dev))
- d = new VI(h);
-// dev->inc_ref_count();
- return d;
- }
-
- VI *vcreate()
- { return 0; }
-
-};
-
-template< typename VI, typename HW >
-class Feature_factory_t
-: public Generic_factory_t<VI, Hw::Dev_feature, HW, Feature_factory >
-{};
-
-template< typename VI, typename HW >
-class Resource_factory_t
-: public Generic_factory_t<VI, Resource, HW, Resource_factory >
-{};
-
-template< typename V_DEV, typename HW_DEV = void >
-class Dev_factory_t : public Dev_factory
-{
-public:
- typedef HW_DEV Hw_dev;
- typedef V_DEV V_dev;
-
- Dev_factory_t() : Dev_factory(&typeid(Hw_dev))
- { }
-
-
- virtual Device *vcreate(Hw::Device *dev)
- {
- if (dev->ref_count())
- printf("WARNING: device '%s' already assigned to an other virtual bus.\n",
- dev->name());
-
- if (!dynamic_cast<HW_DEV const*>(dev))
- return 0;
-
- Device *d = new V_dev(static_cast<Hw_dev*>(dev));
- dev->inc_ref_count();
- return d;
- }
-
- virtual Device *vcreate()
- { return 0; }
-
-};
-
-template< typename V_DEV >
-class Dev_factory_t<V_DEV, void> : public Dev_factory
-{
-public:
- typedef void Hw_dev;
- typedef V_DEV V_dev;
-
- explicit Dev_factory_t(std::string const &_class) : Dev_factory(0)
- { name_map()[_class] = this; }
-
-
- virtual Device *vcreate(Hw::Device *)
- { return 0; }
-
- virtual Device *vcreate()
- { return new V_dev; }
-
-};
-
-template< typename VI, typename HW >
-Generic_type_factory<VI, HW>::Generic_type_factory(std::type_info const *type)
-: _type(type)
-{
- if (!type)
- return;
-
- printf("GTF: register factory for %s\n", type->name());
-
- Iterator i = _for_type.end();
- for (Iterator c = _for_type.begin(); c != _for_type.end(); ++c)
- {
- void *x = 0;
- // use the compiler catch logic to figure out if TYPE
- // is a base class of c->_type, if it is we must put
- // this behind c in the list.
- if (type->__do_catch(c->_type, &x, 0))
- i = c;
- }
-
- _for_type.insert(this, i);
-}
-
-template< typename VI, typename HW >
-VI *
-Generic_type_factory<VI, HW>::create(HW *f, bool warn)
-{
- if (!f)
- return 0;
-
- for (Iterator c = _for_type.begin(); c != _for_type.end(); ++c)
-
- {
- VI *v = c->vcreate(f);
- if (v)
- return v;
- }
-
- if (warn)
- d_printf(DBG_WARN, "WARNING: cannot fabricate buddy object for '%s'\n",
- typeid(*f).name());
- return 0;
-}
-
-}
-
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#include "vdevice.h"
-
-#include <cstring>
-#include <cstdio>
-
-#include "device.h"
-#include <l4/vbus/vdevice-ops.h>
-#include <l4/vbus/vbus_types.h>
-
-namespace Vi {
-
-Device::Dev_set Device::__devs;
-
-bool
-Device::resource_allocated(Resource const *r) const
-{
- if (!parent())
- return false;
-
- return parent()->resource_allocated(r);
-}
-
-
-Device *
-Device::get_dev_by_id(l4vbus_device_handle_t id)
-{
- if (id == 0)
- return this;
- else if (__devs.find(id) != __devs.end())
- return (Device*)id;
- else
- return 0;
-}
-
-struct Match_hid
-{
- char const *hid;
- Device mutable *dev;
-
- int operator () (Device *d) const
- {
- char const *h = d->hid();
- if (h && strcmp(h, hid) == 0)
- {
- dev = d;
- return 1;
- }
- return 0;
- }
-};
-
-int
-Device::get_by_hid(L4::Ipc::Iostream &ios)
-{
- l4vbus_device_handle_t child;
- unsigned long sz;
- char const *hid = 0;
-
- int depth;
-
- ios >> child >> depth >> L4::Ipc::Buf_in<char const>(hid, sz);
-
- //printf("look for '%s' in %p(%x) from %x\n", hid, this, _id, start);
- if (!hid || !sz)
- return -L4_ENOENT;
-
- iterator c;
- if (!child)
- c = begin(depth);
- else if ((c = iterator(this, get_dev_by_id(child), depth)) != end())
- ++c;
-
- if (c == end())
- return -L4_ENODEV;
-
-
- Match_hid mh;
- mh.hid = hid;
- mh.dev = 0;
-
- for (; c != end(); ++c)
- if (mh(*c) == 1)
- return dynamic_cast<Device*>(*c)->vbus_get_device(ios);
-
- return -L4_ENOENT;
-}
-
-
-int
-Device::vbus_get_device(L4::Ipc::Iostream &ios)
-{
- l4vbus_device_t inf;
- inf.num_resources = resources()->size();
- if (hid())
- {
- strncpy(inf.name, name(), sizeof(inf.name));
- inf.name[sizeof(inf.name) - 1] = 0;
- }
- else
- *inf.name = 0;
- inf.type = ~0;
- inf.flags = 0;
- if (children())
- inf.flags |= L4VBUS_DEVICE_F_CHILDREN;
-
- ios << l4vbus_device_handle_t(this);
- ios.put(inf);
- return L4_EOK;
-}
-
-int
-Device::vdevice_dispatch(l4_umword_t obj, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- if (func & L4vbus_vdevice_generic)
- {
- switch (func)
- {
- case L4vbus_vdevice_hid:
- {
- char const *h = hid();
- if (!h)
- return -L4_ENOSYS;
-
- ios << h;
- return L4_EOK;
- }
- case L4vbus_vdevice_adr:
- {
- l4_uint32_t a = adr();
- if (a == l4_uint32_t(~0))
- return -L4_ENOSYS;
-
- ios << a;
- return L4_EOK;
- }
- case L4vbus_vdevice_get_by_hid:
- return get_by_hid(ios);
-
- case L4vbus_vdevice_get_next:
- {
- l4vbus_device_handle_t child;
- int depth;
- ios >> child >> depth;
-
- iterator c;
- if (!child)
- c = begin(depth);
- else
- c = ++iterator(this, get_dev_by_id(child), depth);
-
- if (c == end())
- return -L4_ENODEV;
-
- return dynamic_cast<Device*>(*c)->vbus_get_device(ios);
- }
-
- case L4vbus_vdevice_get_resource:
- {
- int res_idx;
- ios >> res_idx;
- if (res_idx < 0 || (unsigned)res_idx >= resources()->size())
- return -L4_ENOENT;
-
- Resource *r = resources()->at(res_idx);
- l4vbus_resource_t res;
- res.start = r->start();
- res.end = r->end();
- res.type = r->type();
- res.flags = 0;
- ios.put(res);
- return L4_EOK;
- }
-
- default: return -L4_ENOSYS;
- }
- }
-
- for (Feature_list::const_iterator i = _features.begin();
- i != _features.end(); ++i)
- {
- int e = (*i)->dispatch(obj, func, ios);
- if (e != -L4_ENOSYS)
- return e;
- }
-
- return -L4_ENOSYS;
-}
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#pragma once
-
-#include <l4/sys/types.h>
-#include <l4/cxx/avl_set>
-//#include <set>
-#include <string>
-#include <vector>
-#include <l4/cxx/ipc_stream>
-#include <l4/vbus/vbus_types.h>
-#include <cstdio> // dbg
-
-#include "device.h"
-#include <cerrno>
-
-namespace Hw {
-class Dev_feature;
-}
-
-class Resource;
-
-namespace Vi {
-
-class Device;
-
-class Dev_feature
-{
-public:
- virtual ~Dev_feature() {}
- virtual bool match_hw_feature(Hw::Dev_feature const *) const = 0;
- virtual int dispatch(l4_umword_t obj, l4_uint32_t func, L4::Ipc::Iostream &ios) = 0;
- virtual Device *host() const = 0;
- virtual void set_host(Device *d) = 0;
-};
-
-
-class Device : public Generic_device, public Device_tree_mixin<Device>
-{
-public:
- typedef Device_tree_mixin<Device>::iterator iterator;
- using Device_tree_mixin<Device>::begin;
- using Device_tree_mixin<Device>::end;
-
- // dispatch helper for server object
- int vdevice_dispatch(l4_umword_t obj, l4_uint32_t func, L4::Ipc::Iostream &ios);
-
- typedef std::vector<Dev_feature*> Feature_list;
-
- Feature_list const *features() const { return &_features; }
-
- void add_feature(Dev_feature *f)
- {
- f->set_host(this);
- _features.push_back(f);
- }
-
- template< typename FT >
- FT *find_feature()
- {
- for (Feature_list::const_iterator i = _features.begin();
- i != _features.end(); ++i)
- if (FT *r = dynamic_cast<FT*>(*i))
- return r;
-
- return 0;
- }
-
-
- virtual l4_uint32_t adr() const
- { return l4_uint32_t(~0); }
-
- virtual ~Device()
- { __devs.erase(l4vbus_device_handle_t(this)); }
-
- char const *name() const
- { return _name.c_str(); }
-
- bool name(cxx::String const &n)
- {
- _name = std::string(n.start(), n.end());
- return true;
- }
-
- bool resource_allocated(Resource const *) const;
-
- virtual int add_filter(cxx::String const &, cxx::String const &) { return -ENODEV; }
- virtual int add_filter(cxx::String const &, unsigned long long) { return -ENODEV; }
- virtual int add_filter(cxx::String const &, unsigned long long, unsigned long long) { return -ENODEV; }
- virtual void finalize_setup() {}
-
- Device *parent() const { return _dt.parent(); }
- Device *children() const { return _dt.children(); }
- Device *next() const { return _dt.next(); }
- int depth() const { return _dt.depth(); }
-
- Device() : _name("(noname)")
- { __devs.insert(l4vbus_device_handle_t(this)); }
-
-protected:
- // helper functions
- int get_by_hid(L4::Ipc::Iostream &ios);
- int vbus_get_device(L4::Ipc::Iostream &ios);
- Device *get_dev_by_id(l4vbus_device_handle_t id);
-
- Device *get_root()
- {
- Device *d;
- for (d = this; d->parent(); d = d->parent())
- ;
- return d;
- }
-
- std::string _name;
-
- typedef cxx::Avl_set<l4vbus_device_handle_t> Dev_set;
- //typedef std::set<l4vbus_device_handle_t> Dev_set;
- static Dev_set __devs;
-
-private:
- Feature_list _features;
-};
-
-}
+++ /dev/null
-/*
- * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-
-#include "debug.h"
-#include "gpio"
-#include "hw_device.h"
-#include "vdevice.h"
-#include "vbus_factory.h"
-#include "vbus.h"
-#include "vicu.h"
-
-#include <vector>
-
-#include <l4/vbus/vbus_gpio-ops.h>
-
-#include <cerrno>
-
-
-namespace Vi {
-namespace {
-
-class Gpio : public Device, public Dev_feature
-{
-public:
- int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
-
- explicit Gpio(Hw::Device *d)
- : _hwd(dynamic_cast<Hw::Gpio_chip*>(d)), _mask(0)
- {
- add_feature(this);
-
- for (unsigned i = 0; i < Max_pins; ++i)
- _irqs[i] = -1;
- }
-
- int add_filter(cxx::String const &tag, cxx::String const &)
- {
- if (tag != "pins")
- return -L4_ENODEV;
- return -L4_EINVAL;
- }
-
- int add_filter(cxx::String const &tag, unsigned long long val)
- {
- if (tag != "pins")
- return -L4_ENODEV;
- _mask |= (1UL << val);
- return 0;
- }
-
- int add_filter(cxx::String const &tag, unsigned long long s, unsigned long long e)
- {
- if (tag != "pins")
- return -L4_ENODEV;
- _mask |= ~(~0UL << (e - s + 1)) << s;
- return 0;
- }
-
- void modify_mask(l4_uint32_t enable, l4_uint32_t disable)
- {
- _mask = (_mask & ~disable) | enable;
- }
-
- char const *hid() const { return "GPIO"; }
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
- bool match_hw_feature(const Hw::Dev_feature*) const
- { return false; }
-
-private:
- enum { Max_pins = 32 };
- Device *_host;
- Hw::Gpio_chip *_hwd;
- l4_uint32_t _mask;
-
- int _irqs[Max_pins];
-
- int setup(L4::Ipc::Iostream &ios);
- int config_pad(L4::Ipc::Iostream &ios);
- int config_get(L4::Ipc::Iostream &ios);
- int get(L4::Ipc::Iostream &ios);
- int set(L4::Ipc::Iostream &ios);
- int multi_setup(L4::Ipc::Iostream &ios);
- int multi_config_pad(L4::Ipc::Iostream &ios);
- int multi_get(L4::Ipc::Iostream &ios);
- int multi_set(L4::Ipc::Iostream &ios);
- int to_irq(L4::Ipc::Iostream &ios);
-
- void check(unsigned pin)
- {
- if (pin > 31)
- throw -L4_ERANGE;
-
- if (!((1UL << pin) & _mask))
- throw -L4_ERANGE;
- }
-
- void check_mask(unsigned mask)
- {
- if (mask & ~_mask)
- throw -L4_ERANGE;
- }
-};
-
-
-
-int
-Gpio::setup(L4::Ipc::Iostream &ios)
-{
- unsigned pin, mode;
- int value;
- ios >> pin >> mode >> value;
- check(pin);
- _hwd->setup(pin, mode, value);
- return 0;
-}
-
-int
-Gpio::config_pad(L4::Ipc::Iostream &ios)
-{
- unsigned pin, func, value;
- ios >> pin >> func >> value;
- check(pin);
- _hwd->config_pad(pin, _mask, func, value);
- return 0;
-}
-
-int
-Gpio::config_get(L4::Ipc::Iostream &ios)
-{
- unsigned pin, func, value;
- ios >> pin >> func;
- check(pin);
- _hwd->config_get(pin, _mask, func, &value);
- ios << value;
- return 0;
-}
-
-int
-Gpio::get(L4::Ipc::Iostream &ios)
-{
- unsigned pin;
- ios >> pin;
- check(pin);
- return _hwd->get(pin);
-}
-
-int
-Gpio::set(L4::Ipc::Iostream &ios)
-{
- unsigned pin;
- int value;
- ios >> pin >> value;
- check(pin);
- _hwd->set(pin, value);
- return 0;
-}
-
-int
-Gpio::multi_setup(L4::Ipc::Iostream &ios)
-{
- unsigned mask, mode, outvalue;
- ios >> mask >> mode >> outvalue;
- check_mask(mask);
- _hwd->multi_setup(mask, mode, outvalue);
- return 0;
-}
-
-int
-Gpio::multi_config_pad(L4::Ipc::Iostream &ios)
-{
- unsigned mask, func, value;
- ios >> mask >> func >> value;
- check_mask(mask);
- _hwd->multi_config_pad(mask, func, value);
- return 0;
-}
-
-int
-Gpio::multi_get(L4::Ipc::Iostream &ios)
-{
- unsigned data = _hwd->multi_get();
- ios << (unsigned)(data & _mask);
- return 0;
-}
-
-int
-Gpio::multi_set(L4::Ipc::Iostream &ios)
-{
- unsigned mask, data;
- ios >> mask >> data;
- check_mask(mask);
- _hwd->multi_set(mask, data);
- return 0;
-}
-
-int
-Gpio::to_irq(L4::Ipc::Iostream &ios)
-{
- unsigned pin;
- ios >> pin;
- check(pin);
-
- if (_irqs[pin] == -1)
- {
- // we have to allocate the IRQ...
- // if it fails we mark the IRQ as unavailable (-L4_ENODEV)
- _irqs[pin] = -L4_ENODEV;
-
- int irqnum = _hwd->get_irq(pin);
- if (irqnum < 0)
- return irqnum;
-
- if (System_bus *sb = dynamic_cast<System_bus *>(get_root()))
- {
- int virq = sb->sw_icu()->alloc_irq(Sw_icu::S_allow_set_mode,
- Sw_icu::real_irq(irqnum));
- if (virq < 0)
- return virq;
-
- _irqs[pin] = virq;
- return virq;
- }
- return -L4_ENODEV;
- }
- return _irqs[pin];
-}
-
-int
-Gpio::dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- try
- {
- switch (func)
- {
- case L4VBUS_GPIO_OP_SETUP: return setup(ios);
- case L4VBUS_GPIO_OP_CONFIG_PAD: return config_pad(ios);
- case L4VBUS_GPIO_OP_CONFIG_GET: return config_get(ios);
- case L4VBUS_GPIO_OP_GET: return get(ios);
- case L4VBUS_GPIO_OP_SET: return set(ios);
- case L4VBUS_GPIO_OP_MULTI_SETUP: return multi_setup(ios);
- case L4VBUS_GPIO_OP_MULTI_CONFIG_PAD: return multi_config_pad(ios);
- case L4VBUS_GPIO_OP_MULTI_GET: return multi_get(ios);
- case L4VBUS_GPIO_OP_MULTI_SET: return multi_set(ios);
- case L4VBUS_GPIO_OP_TO_IRQ: return to_irq(ios);
- default: return -L4_ENOSYS;
- }
- }
- catch (int err)
- {
- return err;
- }
-}
-
-
-static Dev_factory_t<Gpio, Hw::Gpio_device> __gpio_factory;
-
-class Gpio_resource : public Resource
-{
-public:
- explicit Gpio_resource(::Gpio_resource *hr)
- : Resource(hr->flags(), hr->start(), hr->end()), _hwr(hr) {}
-private:
- ::Gpio_resource *_hwr;
-};
-
-class Root_gpio_rs : public Resource_space
-{
-public:
- explicit Root_gpio_rs(System_bus *bus) : _bus(bus)
- {}
-
- bool request(Resource *parent, ::Device *pdev, Resource *child, ::Device *)
- {
- Vi::System_bus *vsb = dynamic_cast<Vi::System_bus *>(pdev);
- if (!vsb || !parent)
- return false;
-
- ::Gpio_resource *r = dynamic_cast< ::Gpio_resource*>(child);
- if (!r)
- return false;
-
- Hw::Gpio_device *gpio = r->provider();
-
- Vi::Device *vbus = vsb;
-
- for (Hw::Device *bus = system_bus(); bus != gpio; )
- {
- Hw::Device *d = gpio;
- while (d->parent() != bus)
- d = d->parent();
-
- bus = d;
- //printf("BUS: %p:%s\n", bus, bus->name());
-
- Vi::Device *vd = vbus->find_by_name(bus->name());
- if (!vd)
- {
- if (bus != gpio)
- vd = new Vi::Device();
- else
- vd = new Gpio(gpio);
-
- vd->name(bus->name());
- vbus->add_child(vd);
- }
- // printf("VDEV=%p:%s\n", vd, vd ? vd->name() : "");
- vbus = vd;
- }
-
- Gpio *vgpio = dynamic_cast<Gpio *>(vbus);
-
- if (!vgpio)
- {
- d_printf(DBG_ERR, "ERROR: device: %s is not a GPIO device\n", vbus->name());
- return false;
- }
-
- d_printf(DBG_DEBUG2, "Add GPIO resource to vbus: ");
- if (dlevel(DBG_DEBUG2))
- child->dump();
-
-
- {
- unsigned e = r->end() + 1;
- unsigned s = r->start();
- if (e > 31) e = 31;
- if (s > 31) s = 31;
- l4_uint32_t mask = ((1UL << (e - s)) - 1) << s;
- vgpio->modify_mask(mask, 0);
- }
-
- return true;
- }
-
- bool alloc(Resource *parent, ::Device *, Resource *child, ::Device *, bool)
- {
- d_printf(DBG_DEBUG2, "Allocate virtual GPIO resource ...\n");
- if (dlevel(DBG_DEBUG2))
- child->dump();
-
- if (!parent)
- return false;
- return false;
- }
-
-
-private:
- Root_gpio_rs(Root_gpio_rs const &);
- void operator = (Root_gpio_rs const &);
-
- System_bus *_bus;
- std::vector<Gpio *> _gpios;
-};
-
-static System_bus::Root_resource_factory_t<Resource::Gpio_res, Root_gpio_rs> __rf;
-
-}
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include <l4/vbus/vdevice-ops.h>
-
-#include "vicu.h"
-#include "vbus_factory.h"
-#include "server.h"
-#include "main.h"
-#include "debug.h"
-
-#include <l4/re/util/cap_alloc>
-#include <l4/re/namespace>
-#include <l4/re/env>
-#include <l4/re/error_helper>
-#include <l4/sys/icu>
-#include <l4/sys/irq>
-#include <l4/sys/debugger.h>
-#include <l4/sys/kdebug.h>
-
-#include <cassert>
-#include <map>
-
-namespace Vi {
-
-using L4Re::Util::Auto_cap;
-using L4Re::chksys;
-using L4Re::chkcap;
-
-namespace {
-
-typedef std::map<unsigned, Kernel_irq_pin *> Irq_map;
-static Irq_map _real_irqs;
-
-}
-
-Kernel_irq_pin *
-Sw_icu::real_irq(unsigned n)
-{
- Irq_map::const_iterator f = _real_irqs.find(n);
- Kernel_irq_pin *r;
- if (f == _real_irqs.end() || !(*f).second)
- _real_irqs[n] = r = new Kernel_irq_pin(n);
- else
- r = (*f).second;
-
- return r;
-}
-
-
-Sw_icu::Sw_icu()
-{
- add_feature(this);
- registry->register_obj(this);
-}
-
-Sw_icu::~Sw_icu()
-{
- registry->unregister_obj(this);
-}
-
-int
-Sw_icu::bind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &/*irqc*/)
-{
- if (tag.items() < 1)
- return -L4_EINVAL;
-
- d_printf(DBG_ALL, "%s[%p]: bind_irq(%d, ...)\n", name(), this, irqn);
-
- Irq_set::Iterator i = _irqs.find(irqn);
- if (i == _irqs.end())
- return -L4_ENOENT;
-
- int err = i->bind(rcv_cap);
- if (err < 0)
- d_printf(DBG_ERR, "ERROR: binding irq %d, result is %d (%s)\n", irqn, err, l4sys_errtostr(err));
-
- return err;
-}
-
-int
-Sw_icu::unbind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &/*irqc*/)
-{
- if (tag.items() < 1)
- return -L4_EINVAL;
-
- d_printf(DBG_ALL, "%s[%p]: unbind_irq(%d, ...)\n", name(), this, irqn);
-
- Irq_set::Iterator i = _irqs.find(irqn);
- if (i == _irqs.end())
- return -L4_ENOENT;
-
- // could check the validity of the cap too, however we just don't care
- return i->unbind();
-}
-
-int
-Sw_icu::set_mode(l4_msgtag_t /*tag*/, unsigned irqn, l4_umword_t mode)
-{
- Irq_set::Iterator i = _irqs.find(irqn);
- if (i == _irqs.end())
- return -L4_ENOENT;
-
- return i->set_mode(mode);
-}
-
-int
-Sw_icu::unmask_irq(l4_msgtag_t /*tag*/, unsigned irqn)
-{
- Irq_set::Iterator i = _irqs.find(irqn);
- if (i == _irqs.end())
- return -L4_ENOENT;
-
- if (!i->unmask_via_icu())
- return -L4_EINVAL;
-
- return i->unmask();
-}
-
-
-bool
-Sw_icu::irqs_allocated(Resource const *r)
-{
- for (unsigned n = r->start(); n <= r->end(); ++n)
- {
- if (_irqs.find(n) == _irqs.end())
- return false;
- }
-
- return true;
-}
-
-bool
-Sw_icu::add_irqs(Resource const *r)
-{
- for (unsigned n = r->start(); n <= r->end(); ++n)
- {
- if (_irqs.find(n) != _irqs.end())
- continue;
-
- Kernel_irq_pin *ri = real_irq(n);
- if (!ri)
- {
- d_printf(DBG_ERR, "ERROR: No IRQ%d available.\n", n);
- continue;
- }
- Sw_irq_pin *irq = new Sw_irq_pin(ri, n, r->flags());
- _irqs.insert(irq);
- }
- return true;
-}
-
-bool
-Sw_icu::add_irq(unsigned n, unsigned flags, Io_irq_pin *be)
-{
- if (_irqs.find(n) == _irqs.end())
- return false;
-
- Sw_irq_pin *irq = new Sw_irq_pin(be, n, flags);
- _irqs.insert(irq);
- return true;
-}
-
-int
-Sw_icu::alloc_irq(unsigned flags, Io_irq_pin *be)
-{
- unsigned i;
- for (i = 1; i < 1000; ++i)
- if (_irqs.find(i) == _irqs.end())
- break;
-
- if (i == 1000)
- return -1;
-
- Sw_irq_pin *irq = new Sw_irq_pin(be, i, flags);
- _irqs.insert(irq);
- return i;
-}
-
-
-int
-Sw_icu::dispatch(l4_umword_t /*obj*/, L4::Ipc::Iostream &ios)
-{
- l4_umword_t op, irqn;
- L4::Ipc::Snd_fpage irqc;
- l4_msgtag_t tag;
- ios >> tag >> op >> irqn;
-
- if (tag.label() != L4_PROTO_IRQ)
- return -L4_EBADPROTO;
-
- switch (op)
- {
- case L4_ICU_OP_BIND:
- ios >> irqc;
- return bind_irq(tag, irqn, irqc);
-
- case L4_ICU_OP_UNBIND:
- ios >> irqc;
- return unbind_irq(tag, irqn, irqc);
-
- case L4_ICU_OP_UNMASK:
- unmask_irq(tag, irqn);
- return -L4_ENOREPLY;
-
- case L4_ICU_OP_SET_MODE:
- {
- l4_umword_t mode;
- ios >> mode;
- return set_mode(tag, irqn, mode);
- }
-
- default: return -L4_ENOSYS;
- }
-}
-
-int
-Sw_icu::dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- if (func != L4vbus_vicu_get_cap)
- return -L4_ENOSYS;
-
- ios << obj_cap();
- return L4_EOK;
-}
-
-//static VBus_factory<Sw_icu> __vicu_factory("Vicu");
-
-int
-Sw_icu::Sw_irq_pin::trigger() const
-{
- return l4_error(_irq->trigger());
-}
-
-
-unsigned
-Sw_icu::Sw_irq_pin::l4_type() const
-{
- unsigned m = type();
- unsigned r = (m & S_irq_type_mask) / Resource::Irq_type_base;
- return r;
-}
-
-int
-Sw_icu::Sw_irq_pin::set_mode(l4_umword_t mode)
-{
- if (!(_state & S_allow_set_mode))
- {
- unsigned t = l4_type();
-
- mode = (mode & L4_IRQ_F_MASK) | 1;
-
- if (t != L4_IRQ_F_NONE
- && t != mode)
- d_printf(DBG_WARN, "WARNING: Changing type of IRQ %d from %x to %lx prohibited\n",
- _irqn, t, mode);
- return 0;
- }
-
- return _master->set_mode(mode);
-}
-
-void
-Sw_icu::Sw_irq_pin::allocate_master_irq()
-{
- assert (_master->shared());
- Auto_cap<L4::Irq>::Cap lirq = chkcap(L4Re::Util::cap_alloc.alloc<L4::Irq>(),
- "allocating IRQ capability");
- // printf("IRQ mode = %x -> %x\n", type(), l4_type());
- chksys(L4Re::Env::env()->factory()->create(lirq.get(), L4_PROTO_IRQ) << l4_umword_t(1), "allocating IRQ");
- chksys(_master->bind(lirq.get(), l4_type()), "binding IRQ");
- _master->irq(lirq.release());
- _master->set_chained(true);
-}
-
-
-int
-Sw_icu::Sw_irq_pin::bind(L4::Cap<void> rc)
-{
- if (_irq.is_valid())
- {
- if (_irq.get().validate(L4Re::This_task).label() > 0)
- return -L4_EEXIST;
-
- _unbind();
- }
-
- if (bound())
- return -L4_EPERM;
-
- Auto_cap<L4::Irq>::Cap irq =
- chkcap(L4Re::Util::cap_alloc.alloc<L4::Irq>(), "allocating IRQ capability");
-
- irq.get().move(L4::cap_cast<L4::Irq>(rc));
-
- if (_master->shared() && !_master->chained() && _master->sw_irqs() == 0)
- {
- allocate_master_irq();
- assert (_master->chained());
- }
-
- if (!_master->chained())
- {
- // the first irq shall be attached to a hw irq
- d_printf(DBG_DEBUG2, "IRQ %d -> client\nIRQ mode = %x -> %x\n",
- irqn(), type(), l4_type());
- int err = _master->bind(irq.get(), l4_type());
- if (err < 0)
- return err;
-
- _irq = irq;
- _master->irq(_irq.get());
- _master->inc_sw_irqs();
- _state |= S_bound;
- if (err == 1)
- _state |= S_unmask_via_icu;
-
- d_printf(DBG_DEBUG2, " bound irq %u -> err=%d\n", irqn(), err);
- return err;
- }
-
- d_printf(DBG_DEBUG2, "IRQ %d -> proxy -> %d clients\n", irqn(), _master->sw_irqs() + 1);
- L4Re::chksys(_master->irq()->chain(l4_umword_t(_master), irq.get()), "attach");
- _irq = irq;
- _master->inc_sw_irqs();
-
- return 0;
-}
-
-int
-Sw_icu::Sw_irq_pin::_unbind()
-{
- int err = 0;
- _master->dec_sw_irqs();
- if (_master->sw_irqs() == 0)
- {
- if (_master->chained())
- L4Re::Util::cap_alloc.free(_master->irq());
-
- _master->irq(L4::Cap<L4::Irq>::Invalid);
- _master->set_chained(false);
- }
-
- _irq = L4::Cap<L4::Irq>::Invalid;
-
- _state &= ~S_bound;
- return err;
-}
-
-int
-Sw_icu::Sw_irq_pin::unbind()
-{
- if (!_master)
- return -L4_EINVAL;
-
- if (!_master->sw_irqs())
- return -L4_EINVAL;
-
- return _unbind();
-}
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#pragma once
-
-#include <l4/sys/capability>
-#include <l4/sys/irq>
-#include <l4/sys/icu>
-
-#include <l4/cxx/ipc_server>
-#include <l4/cxx/avl_tree>
-#include <l4/cxx/list>
-
-#include <l4/re/util/cap_alloc>
-
-#include "irqs.h"
-#include "vdevice.h"
-
-namespace Vi {
-
-class Sw_icu : public Device, public Dev_feature, public L4::Server_object
-{
-public:
- Sw_icu();
- virtual ~Sw_icu();
-
- int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
-
- char const *hid() const { return "L40009"; }
- int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
- bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
-
- bool add_irqs(Resource const *r);
- bool add_irq(unsigned n, unsigned flags, Io_irq_pin *be);
- int alloc_irq(unsigned flags, Io_irq_pin *be);
- bool irqs_allocated(Resource const *r);
-
-private:
- int bind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &irqc);
- int unbind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &irqc);
- int unmask_irq(l4_msgtag_t tag, unsigned irqn);
- int set_mode(l4_msgtag_t tag, unsigned irqn, l4_umword_t mode);
-
-
- class Sw_irq_pin : public cxx::Avl_tree_node
- {
- private:
- enum
- {
- S_bound = 1,
- S_unmask_via_icu = 2,
- };
-
- unsigned _state;
- unsigned _irqn;
- Io_irq_pin *_master;
- L4Re::Util::Auto_cap<L4::Irq>::Cap _irq;
-
- public:
- enum Irq_type
- {
- S_irq_type_mask = Resource::Irq_type_mask,
- };
-
- enum
- {
- S_allow_set_mode = 4,
- S_user_mask = S_irq_type_mask | S_allow_set_mode
- };
-
- typedef unsigned Key_type;
-
- static unsigned key_of(Sw_irq_pin const *o) { return o->_irqn; }
-
- Sw_irq_pin(Io_irq_pin *master, unsigned irqn, unsigned flags)
- : _state(flags & S_user_mask), _irqn(irqn), _master(master)
- {
- master->add_sw_irq();
- }
-
- unsigned irqn() const { return _irqn; }
- L4::Cap<L4::Irq> irq() const { return _irq.get(); }
-
- bool bound() const { return _state & S_bound; }
- bool unmask_via_icu() const { return _state & S_unmask_via_icu; }
- unsigned type() const { return _state & S_irq_type_mask; }
- unsigned l4_type() const;
- int bind(L4::Cap<void> rc);
- int unmask() { return _master->unmask(); }
- int unbind();
- int set_mode(l4_umword_t mode);
- int trigger() const;
-
- protected:
- int _unbind();
-// int share(L4Re::Util::Auto_cap<L4::Irq>::Cap const &irq);
- void allocate_master_irq();
- };
-
- typedef cxx::Avl_tree<Sw_irq_pin, Sw_irq_pin> Irq_set;
- Irq_set _irqs;
-
-public:
- static Kernel_irq_pin *real_irq(unsigned n);
-
- enum
- {
- S_allow_set_mode = Sw_irq_pin::S_allow_set_mode,
- };
-
- static void *irq_loop(void*);
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
-private:
- Device *_host;
-};
-
-}
+++ /dev/null
-/*
- * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "vbus_factory.h"
-#include "resource.h"
-#include "hw_msi.h"
-#include "vmsi.h"
-#include "debug.h"
-
-namespace Vi {
- Msi_resource::Msi_resource(Hw::Msi_resource *hr)
- : Resource(Resource::Irq_res | Resource::Irq_type_falling_edge | Resource::F_disabled, 0, 0), _hw_msi(hr)
- {
- d_printf(DBG_ALL, "Create virtual MSI wrapper for MSI %ld\n", _hw_msi->start());
- }
-}
-
-namespace {
- static Vi::Resource_factory_t<Vi::Msi_resource, Hw::Msi_resource> __vmsifactory;
-}
-
+++ /dev/null
-#pragma once
-
-#include "resource.h"
-
-namespace Hw {
- class Msi_resource;
-}
-
-namespace Vi {
- class Msi_resource : public Resource
- {
- private:
- Hw::Msi_resource *_hw_msi;
-
- public:
- Msi_resource(Hw::Msi_resource *hr);
- Hw::Msi_resource *hw_msi() const { return _hw_msi; }
- };
-
-}
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include <l4/vbus/vdevice-ops.h>
-
-#include <cassert>
-#include <cstring>
-#include <cstdlib>
-#include <l4/cxx/exceptions>
-#include <l4/io/pciids.h>
-#include <l4/sys/err.h>
-
-#include "debug.h"
-#include "pci.h"
-#include "vpci.h"
-#include "vbus_factory.h"
-
-namespace Vi {
-
-// -----------------------------------------------------------------------
-// Pci_virtual_dev
-// -----------------------------------------------------------------------
-
-Pci_virtual_dev::Pci_virtual_dev()
-{
- memset(&_h, 0, sizeof(_h));
-}
-
-int
-Pci_virtual_dev::cfg_read(int reg, l4_uint32_t *v, Cfg_width order)
-{
- reg >>= order;
- if ((unsigned)reg >= (_h_len >> order))
- return -L4_ERANGE;
-
-#define RC(x) *v = *((Hw::Pci::Cfg_type<x>::Type const *)_h + reg); break
- *v = 0;
- switch (order)
- {
- case Hw::Pci::Cfg_byte: RC(Hw::Pci::Cfg_byte);
- case Hw::Pci::Cfg_short: RC(Hw::Pci::Cfg_short);
- case Hw::Pci::Cfg_long: RC(Hw::Pci::Cfg_long);
- }
-
- return 0;
-#undef RC
-}
-
-int
-Pci_virtual_dev::cfg_write(int reg, l4_uint32_t v, Cfg_width order)
-{
- switch (reg & ~3)
- {
- case 0x4: // status is RO
- v &= 0x0000ffff << (reg & (3 >> order));
- break;
-
- default:
- break;
- }
-
- reg >>= order;
- if ((unsigned)reg >= (_h_len >> order))
- return -L4_ERANGE;
-
-#define RC(x) *((Hw::Pci::Cfg_type<x>::Type *)_h + reg) = v; break
- switch (order)
- {
- case Hw::Pci::Cfg_byte: RC(Hw::Pci::Cfg_byte);
- case Hw::Pci::Cfg_short: RC(Hw::Pci::Cfg_short);
- case Hw::Pci::Cfg_long: RC(Hw::Pci::Cfg_long);
- }
-
- return 0;
-#undef RC
-}
-
-
-
-// -----------------------------------------------------------------------
-// Pci_proxy_dev
-// -----------------------------------------------------------------------
-
-Pci_proxy_dev::Pci_proxy_dev(Hw::Pci::If *hwf)
-: _hwf(hwf), _rom(0)
-{
- assert (hwf);
- for (int i = 0; i < 6; ++i)
- {
- Resource *r = _hwf->bar(i);
-
- if (!r)
- {
- _vbars[i] = 0;
- continue;
- }
-
- if (_hwf->is_64bit_high_bar(i))
- {
- _vbars[i] = l4_uint64_t(r->start()) >> 32;
- }
- else
- {
- _vbars[i] = r->start();
- if (r->type() == Resource::Io_res)
- _vbars[i] |= 1;
-
- if (r->is_64bit())
- _vbars[i] |= 4;
-
- if (r->prefetchable())
- _vbars[i] |= 8;
-
- }
-
- //printf(" bar: %d = %08x\n", i, _vbars[i]);
- }
-
- if (_hwf->rom())
- _rom = _hwf->rom()->start();
-}
-
-int
-Pci_proxy_dev::irq_enable(Irq_info *irq)
-{
- for (Resource_list::const_iterator i = host()->resources()->begin();
- i != host()->resources()->end(); ++i)
- {
- Resource *res = *i;
-
- if (res->type() == Resource::Irq_res)
- {
- irq->irq = res->start();
- irq->trigger = !res->irq_is_level_triggered();
- irq->polarity = res->irq_is_low_polarity();
- d_printf(DBG_DEBUG, "Enable IRQ: %d %x %x\n", irq->irq, irq->trigger, irq->polarity);
- if (dlevel(DBG_DEBUG2))
- dump();
- return 0;
- }
- }
- return -L4_EINVAL;
-}
-
-
-
-l4_uint32_t
-Pci_proxy_dev::read_bar(int bar)
-{
- // d_printf(DBG_ALL, " read bar[%x]: %08x\n", bar, _vbars[bar]);
- return _vbars[bar];
-}
-
-void
-Pci_proxy_dev::write_bar(int bar, l4_uint32_t v)
-{
- Hw::Pci::If *p = _hwf;
-
- Resource *r = p->bar(bar);
- if (!r)
- return;
-
- // printf(" write bar[%x]: %llx-%llx...\n", bar, r->abs_start(), r->abs_end());
- l4_uint64_t size_mask = r->alignment();
-
- if (r->type() == Resource::Io_res)
- size_mask |= 0xffff0000;
-
- if (p->is_64bit_high_bar(bar))
- size_mask >>= 32;
-
- _vbars[bar] = (_vbars[bar] & size_mask) | (v & ~size_mask);
-
- // printf(" bar=%lx\n", _vbars[bar]);
-}
-
-void
-Pci_proxy_dev::write_rom(l4_uint32_t v)
-{
- Hw::Pci::If *p = _hwf;
-
- // printf("write rom bar %x %p\n", v, _dev->rom());
- Resource *r = p->rom();
- if (!r)
- return;
-
- l4_uint64_t size_mask = r->alignment();
-
- _rom = (_rom & size_mask) | (v & (~size_mask | 1));
-
- p->cfg_write(0x30, (r->start() & ~1U) | (v & 1), Hw::Pci::Cfg_long);
-}
-
-int
-Pci_proxy_dev::cfg_read(int reg, l4_uint32_t *v, Cfg_width order)
-{
- Hw::Pci::If *p = _hwf;
-
- l4_uint32_t buf;
- l4_uint32_t const *r = &buf;
- reg &= ~0U << order;
- int dw = reg >> 2;
- switch (dw)
- {
- case 0: case 2: case 11:
- r = p->cfg_word(dw); break;
- case 1: return p->cfg_read(reg, v, order);
- case 3: //buf = l4_uint32_t(_dev->hdr_type) << 16; break;
- p->cfg_read(dw * 4, &buf, Hw::Pci::Cfg_long);
- buf |= 0x00800000;
- break;
- case 4: case 5: case 6: case 7: case 8: case 9:
- buf = read_bar(dw-4); break;
- case 12: buf = read_rom(); break;
- default: return p->cfg_read(reg, v, order); //buf = 0; break;
- }
-
- unsigned mask = ~0U >> (32 - (1U << (order + 3)));
- *v = (*r >> ((reg & 3) *8)) & mask;
- return L4_EOK;
-}
-
-int
-Pci_proxy_dev::cfg_write(int reg, l4_uint32_t v, Cfg_width order)
-{
- Hw::Pci::If *p = _hwf;
-
- reg &= ~0U << order;
- int dw = reg >> 2;
- switch (dw)
- {
- case 4: case 5: case 6: case 7: case 8: case 9: case 12: break;
- default: return p->cfg_write(reg, v, order);
- }
-
- l4_uint32_t old;
- if (order < 2)
- cfg_read(reg, &old, Hw::Pci::Cfg_long);
-
- l4_uint32_t mask = ~0U >> (32 - (1U << (order + 3)));
- l4_uint32_t sh = (reg & 3) * 8;
- old &= ~(mask << sh);
- old |= (v & mask) << sh;
-
- switch (dw)
- {
- case 4: case 5: case 6: case 7: case 8: case 9:
- write_bar(dw-4, old); break;
- case 12: write_rom(old); break;
- default: break;
- }
- return L4_EOK;
-}
-
-void
-Pci_proxy_dev::dump() const
-{
- Hw::Pci::If *p = _hwf;
-
- printf(" %04x:%02x:%02x.%x:\n",
- 0, p->bus_nr(), _hwf->host()->adr() >> 16, _hwf->host()->adr() & 0xffff);
-#if 0
- char buf[130];
- libpciids_name_device(buf, sizeof(buf), _dev->vendor(), _dev->device());
- printf(" %s\n", buf);
-#endif
-}
-
-
-// -----------------------------------------------------------------------
-// Virtual PCI dummy device
-// -----------------------------------------------------------------------
-
-class Pci_dummy : public Pci_virtual_dev, public Device
-{
-private:
- unsigned char _cfg_space[4*4];
-
-public:
- int irq_enable(Irq_info *irq)
- {
- irq->irq = -1;
- return -1;
- }
-
- Pci_dummy()
- {
- add_feature(this);
- _h = &_cfg_space[0];
- _h_len = sizeof(_cfg_space);
- cfg_hdr()->hdr_type = 0x80;
- cfg_hdr()->vendor_device = 0x02000400;
- cfg_hdr()->status = 0;
- cfg_hdr()->class_rev = 0x36440000;
- cfg_hdr()->cmd = 0x0;
- }
-
- bool match_hw_feature(const Hw::Dev_feature*) const { return false; }
- int dispatch(l4_umword_t, l4_uint32_t, L4::Ipc::Iostream&)
- { return -L4_ENOSYS; }
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
-private:
- Device *_host;
-};
-
-
-// ----------------------------------------------------------------------
-// Basic virtual PCI bridge functionality
-// ----------------------------------------------------------------------
-
-Pci_bridge::Dev::Dev()
-{
- memset(_fns, 0, sizeof(_fns));
-}
-
-void
-Pci_bridge::Dev::add_fn(Pci_dev *f)
-{
- for (unsigned i = 0; i < sizeof(_fns)/sizeof(_fns[0]); ++i)
- {
- if (!_fns[i])
- {
- _fns[i] = f;
- return;
- }
- }
-}
-
-void
-Pci_bridge::Dev::sort_fns()
-{
- // disabled sorting because the relation of two functions is questionable
-#if 0
- unsigned n;
- for (n = 0; n < sizeof(_fns)/sizeof(_fns[0]) && _fns[n]; ++n)
- ;
-
- if (n < 2)
- return;
-
- bool exchg = false;
-
- do
- {
- exchg = false;
- for (unsigned i = 0; i < n - 1; ++i)
- {
- if (_fns[i]->dev()->function_nr() > _fns[i+1]->dev()->function_nr())
- {
- Pci_dev *t = _fns[i];
- _fns[i] = _fns[i+1];
- _fns[i+1] = t;
- exchg = true;
- }
- }
- n -= 1;
- }
- while (exchg && n >= 1);
-#endif
-}
-
-void
-Pci_bridge::Bus::add_fn(Pci_dev *pd, int slot)
-{
- if (slot >= 0)
- {
- _devs[slot].add_fn(pd);
- _devs[slot].sort_fns();
- return;
- }
-
- for (unsigned d = 0; d < Devs && !_devs[d].empty(); ++d)
- if (_devs[d].cmp(pd))
- {
- _devs[d].add_fn(pd);
- _devs[d].sort_fns();
- return;
- }
-
- for (unsigned d = 0; d < Devs; ++d)
- if (_devs[d].empty())
- {
- _devs[d].add_fn(pd);
- return;
- }
-}
-
-void
-Pci_bridge::add_child(Device *d)
-{
- Pci_dev *vp = d->find_feature<Pci_dev>();
-
- // hm, we do currently not add non PCI devices.
- if (!vp)
- return;
-
- _bus.add_fn(vp);
- Device::add_child(d);
-}
-
-
-void
-Pci_bridge::add_child_fixed(Device *d, Pci_dev *vp, unsigned dn, unsigned fn)
-{
- _bus.dev(dn)->fn(fn, vp);
- Device::add_child(d);
-}
-
-
-Pci_bridge *
-Pci_bridge::find_bridge(unsigned bus)
-{
- // printf("PCI[%p]: look for bridge for bus %x %02x %02x\n", this, bus, _subordinate, _secondary);
- if (bus == _secondary)
- return this;
-
- if (bus < _secondary || bus > _subordinate)
- return 0;
-
- for (unsigned d = 0; d < Bus::Devs; ++d)
- for (unsigned f = 0; f < Dev::Fns; ++f)
- {
- Pci_dev *p = _bus.dev(d)->fn(f);
- if (!p)
- break;
-
- Pci_bridge *b = dynamic_cast<Pci_bridge*>(p);
- if (b && (b = b->find_bridge(bus)))
- return b;
- }
-
- return 0;
-}
-
-
-bool
-Pci_bridge::child_dev(unsigned bus, unsigned char dev, unsigned char fn,
- Pci_dev **rd)
-{
- Pci_bridge *b = find_bridge(bus);
- if (!b)
- {
- *rd = 0;
- return true;
- }
-
- if (dev >= Bus::Devs || fn >= Dev::Fns)
- {
- *rd = 0;
- return true;
- }
-
- *rd = b->_bus.dev(dev)->fn(fn);
- return true;
-}
-
-void
-Pci_bridge::setup_bus()
-{
- for (unsigned d = 0; d < Bus::Devs; ++d)
- for (unsigned f = 0; f < Dev::Fns; ++f)
- {
- Pci_dev *p = _bus.dev(d)->fn(f);
- if (!p)
- break;
-
- Pci_bridge *b = dynamic_cast<Pci_bridge*>(p);
- if (b)
- {
- b->_primary = _secondary;
- if (b->_secondary <= _secondary)
- {
- b->_secondary = ++_subordinate;
- b->_subordinate = b->_secondary;
- }
-
- b->setup_bus();
-
- if (_subordinate < b->_subordinate)
- _subordinate = b->_subordinate;
- }
- }
-}
-
-void
-Pci_bridge::finalize_setup()
-{
- for (unsigned dn = 0; dn < Bus::Devs; ++dn)
- {
- if (!_bus.dev(dn)->empty())
- continue;
-
- for (unsigned fn = 0; fn < Dev::Fns; ++fn)
- if (_bus.dev(dn)->fn(fn))
- {
- Pci_dummy *dummy = new Pci_dummy();
- _bus.dev(dn)->fn(0, dummy);
- Device::add_child(dummy);
- break;
- }
- }
-#if 0
- for (VDevice *c = dynamic_cast<VDevice*>(children()); c; c = c->next())
- c->finalize_setup();
-#endif
-}
-
-namespace {
- static Feature_factory_t<Pci_proxy_dev, ::Pci_dev> __pci_f_factory1;
- static Dev_factory_t<Pci_dummy> __pci_dummy_factory("PCI_dummy_device");
-}
-
-}
-
+++ /dev/null
-/*
- * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
- * Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-#pragma once
-
-#include "vdevice.h"
-#include "pci.h"
-
-namespace Vi {
-
-/**
- * \brief Generic virtual PCI device.
- * This class provides the basic functionality for a device on a
- * virtual PCI bus. Implementations may provide proxy access to a real PCI
- * device or a completely virtualized PCI device.
- */
-class Pci_dev
-{
-private:
- void operator = (Pci_dev const &);
- Pci_dev(Pci_dev const &);
-
-public:
- typedef Hw::Pci::Cfg_width Cfg_width;
-
- struct Irq_info
- {
- int irq;
- unsigned char trigger;
- unsigned char polarity;
- };
-
- Pci_dev() {}
- virtual int cfg_read(int reg, l4_uint32_t *v, Cfg_width) = 0;
- virtual int cfg_write(int reg, l4_uint32_t v, Cfg_width) = 0;
- virtual int irq_enable(Irq_info *irq) = 0;
- virtual bool is_same_device(Pci_dev const *o) const = 0;
- virtual ~Pci_dev() = 0;
-};
-
-inline
-Pci_dev::~Pci_dev()
-{}
-
-/**
- * \brief A basic really virtualized PCI device.
- */
-class Pci_virtual_dev : public Pci_dev, public Dev_feature
-{
-public:
- struct Pci_cfg_header
- {
- l4_uint32_t vendor_device;
- l4_uint16_t cmd;
- l4_uint16_t status;
- l4_uint32_t class_rev;
- l4_uint8_t cls;
- l4_uint8_t lat;
- l4_uint8_t hdr_type;
- l4_uint8_t bist;
- } __attribute__((packed));
-
- Pci_cfg_header *cfg_hdr() { return (Pci_cfg_header*)_h; }
- Pci_cfg_header const *cfg_hdr() const { return (Pci_cfg_header const *)_h; }
-
- int cfg_read(int reg, l4_uint32_t *v, Cfg_width);
- int cfg_write(int reg, l4_uint32_t v, Cfg_width);
- bool is_same_device(Pci_dev const *o) const { return o == this; }
-
- ~Pci_virtual_dev() = 0;
-
- Pci_virtual_dev();
-
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
-protected:
- Device *_host;
- unsigned char *_h;
- unsigned _h_len;
-
-};
-
-inline
-Pci_virtual_dev::~Pci_virtual_dev()
-{}
-
-
-
-/**
- * \brief A virtual PCI proxy for a real PCI device.
- */
-class Pci_proxy_dev : public Pci_dev, public virtual Dev_feature
-{
-public:
-
- Pci_proxy_dev(Hw::Pci::If *hwf);
-
- int cfg_read(int reg, l4_uint32_t *v, Cfg_width);
- int cfg_write(int reg, l4_uint32_t v, Cfg_width);
- int irq_enable(Irq_info *irq);
-
- l4_uint32_t read_bar(int bar);
- void write_bar(int bar, l4_uint32_t v);
-
- l4_uint32_t read_rom() const { return _rom; }
- void write_rom(l4_uint32_t v);
-
- int vbus_dispatch(l4_umword_t, l4_uint32_t, L4::Ipc::Iostream &)
- { return -L4_ENOSYS; }
-
- Hw::Pci::If *hwf() const { return _hwf; }
-
- void dump() const;
- bool is_same_device(Pci_dev const *o) const
- {
- if (Pci_proxy_dev const *op = dynamic_cast<Pci_proxy_dev const *>(o))
- return (hwf()->bus_nr() == op->hwf()->bus_nr())
- && ((hwf()->host()->adr() >> 16) == (op->hwf()->host()->adr() >> 16));
- return false;
- }
-
- bool match_hw_feature(const Hw::Dev_feature *f) const
- { return f == _hwf; }
-
- int dispatch(l4_umword_t, l4_uint32_t, L4::Ipc::Iostream&)
- { return -L4_ENOSYS; }
-
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
-private:
- Device *_host;
- Hw::Pci::If *_hwf;
-
- l4_uint32_t _vbars[6];
- l4_uint32_t _rom;
-};
-
-
-
-/**
- * \brief a basic virtual PCI bridge.
- * This class is the base for virtual Host-to-PCI bridges,
- * for virtual PCI-to-PCI bridges, and also for this such as
- * virtual PCI-to-Cardbus brdiges.
- */
-class Pci_bridge : public Device
-{
-public:
- class Dev
- {
- public:
- enum { Fns = 8 };
-
- private:
- Pci_dev *_fns[Fns];
-
- public:
- Dev();
-
- bool empty() const { return !_fns[0]; }
- void add_fn(Pci_dev *f);
- void sort_fns();
-
- Pci_dev *fn(unsigned f) const { return _fns[f]; }
- void fn(unsigned f, Pci_dev *fn) { _fns[f] = fn; }
- bool cmp(Pci_dev const *od) const
- {
- if (empty())
- return false;
-
- return _fns[0]->is_same_device(od);
- }
- };
-
- class Bus
- {
- public:
- enum { Devs = 32 };
-
- private:
- Dev _devs[Devs];
-
- public:
- Dev const *dev(unsigned slot) const { return &_devs[slot]; }
- Dev *dev(unsigned slot) { return &_devs[slot]; }
-
- void add_fn(Pci_dev *d, int slot = -1);
- };
-
- Pci_bridge() : _free_dev(0), _primary(0), _secondary(0), _subordinate(0) {}
-
-protected:
- Bus _bus;
- unsigned _free_dev;
- union
- {
- struct
- {
- l4_uint32_t _primary:8;
- l4_uint32_t _secondary:8;
- l4_uint32_t _subordinate:8;
- l4_uint32_t _lat:8;
- };
- l4_uint32_t _bus_config;
- };
-
-public:
-
- void primary(unsigned char v) { _primary = v; }
- void secondary(unsigned char v) { _secondary = v; }
- void subordinate(unsigned char v) { _subordinate = v; }
- bool child_dev(unsigned bus, unsigned char dev, unsigned char fn, Pci_dev **rd);
- void add_child(Device *d);
- void add_child_fixed(Device *d, Pci_dev *vp, unsigned dn, unsigned fn);
-
- Pci_bridge *find_bridge(unsigned bus);
- void setup_bus();
- void finalize_setup();
-
-};
-
-}
-
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "vpci_pci_bridge.h"
-#include "vbus_factory.h"
-
-namespace Vi {
-
-Pci_to_pci_bridge::Pci_to_pci_bridge()
-{
- add_feature(this);
- _h = &_cfg_space[0];
- _h_len = sizeof(_cfg_space);
- cfg_hdr()->hdr_type = 1;
- cfg_hdr()->vendor_device = 0x02000400;
- cfg_hdr()->status = 0;
- cfg_hdr()->class_rev = 0x06040000;
- cfg_hdr()->cmd = 0x3;
-
- cfg_write(::Pci_dev::C_primary, 0x00010100, Hw::Pci::Cfg_long);
-
- Bridge_cfg *bc = bridge_cfg();
- bc->io_base = 0xc0; bc->io_base_upper = 0;
- bc->io_limit = 0xf0; bc->io_limit_upper = 0;
- bc->mem_base = 0xa000;
- bc->mem_limit = 0xeff0;
- bc->pref_base = 0xf001; bc->pref_base_upper = 0;
- bc->pref_limit = 0xfff1; bc->pref_limit_upper = 0; //0xffffffff;
-}
-
-
-int
-Pci_to_pci_bridge::cfg_read(int reg, l4_uint32_t *v, Cfg_width o)
-{
- unsigned mask = ~0U >> (32 - (1U << (o + 3)));
- switch (reg & ~3)
- {
- case 0x18: // bus config stuff
- *v = (_bus_config >> ((reg & 3)*8)) & mask;
- return L4_EOK;
-
- case 0x10: // We have no BARs
- case 0x14:
- case 0x38:
- *v = 0;
- return L4_EOK;
-
- default:
- break;
- }
-
- return Pci_virtual_dev::cfg_read(reg, v, o);
-}
-
-
-int
-Pci_to_pci_bridge::cfg_write(int reg, l4_uint32_t v, Cfg_width o)
-{
- unsigned mask = (~0U >> (32 - (1U << (o + 3)))) << ((reg & 3) * 8);
- switch (reg & ~3)
- {
- case 0x18:
- _bus_config = (_bus_config & ~mask) | ((v << ((reg & 3)*8)) & mask);
- return L4_EOK;
-
- case 0x10: // We have no BARs
- case 0x14:
- case 0x38:
- return L4_EOK;
-
- default:
- break;
- }
- int r = Pci_virtual_dev::cfg_write(reg, v, o);
-
- switch (reg & ~3)
- {
- case 0x1c:
- *(l4_uint32_t*)(_h + 0x1c) &= 0x0000f000;
- break;
- case 0x24:
- *(l4_uint32_t*)(_h + 0x24) &= 0xfff0fff0;
- *(l4_uint32_t*)(_h + 0x24) |= 0x00010001;
- break;
- case 0x22:
- *(l4_uint32_t*)(_h + 0x22) &= 0xfff0fff0;
- break;
- }
-
- return r;
-}
-
-
-static Dev_factory_t<Pci_to_pci_bridge> __pci_to_pci_factory("PCI_PCI_bridge");
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#pragma once
-
-#include "vpci.h"
-
-namespace Vi {
-
-// -----------------------------------------------------------------------
-// Virtual PCI to PCI bridge
-// -----------------------------------------------------------------------
-
-class Pci_to_pci_bridge : public Pci_bridge, public Pci_virtual_dev
-{
-private:
- unsigned char _cfg_space[16*4];
-
-public:
- struct Bridge_cfg
- {
- l4_uint8_t io_base;
- l4_uint8_t io_limit;
- l4_uint16_t sec_status;
- l4_uint16_t mem_base;
- l4_uint16_t mem_limit;
- l4_uint16_t pref_base;
- l4_uint16_t pref_limit;
- l4_uint32_t pref_base_upper;
- l4_uint32_t pref_limit_upper;
- l4_uint16_t io_base_upper;
- l4_uint16_t io_limit_upper;
- } __attribute__((packed));
-
- Pci_to_pci_bridge();
- int cfg_read(int reg, l4_uint32_t *v, Cfg_width o);
- int cfg_write(int reg, l4_uint32_t v, Cfg_width o);
-
- int irq_enable(Irq_info *irq)
- {
- irq->irq = -1;
- return -1;
- }
-
- Bridge_cfg *bridge_cfg() const
- { return reinterpret_cast<Bridge_cfg*>(_h + 7 * 4); }
-
- bool is_vpci_bridge() const { return true; }
-
- bool match_hw_feature(const Hw::Dev_feature*) const { return false; }
- int dispatch(l4_umword_t, l4_uint32_t, L4::Ipc::Iostream&)
- { return -L4_ENOSYS; }
-
-
-};
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "vdevice.h"
-#include "vpci.h"
-
-// ------------------------------------------------------------------------
-// Proxy for a real PCI root bridge
-// ------------------------------------------------------------------------
-
-class VPci_root : public VDevice
-{
-public:
-
- int vbus_dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
-
- explicit VPci_root() : VDevice() {}
-
- ~VPci_root() {}
-
- char const *hid() const
- {
- return "PNP0A03";
- }
-
-public:
- int cfg_read(L4::Ipc::Iostream &ios);
- int cfg_write(L4::Ipc::Iostream &ios);
- int irq_enable(L4::Ipc::Iostream &ios);
-};
-
-
-// IMPLEMENTATION --------------------------------------------------------
-
-int
-VPci_root::cfg_read(L4::Ipc::Iostream &ios)
-{
- l4_uint32_t bus;
- l4_uint32_t devfn;
- l4_uint32_t reg;
- l4_uint32_t value;
- l4_uint32_t width;
-
- ios >> bus >> devfn >> reg >> width;
-
- int res = pci_root_bridge(0)->cfg_read(bus, devfn, reg, &value, Pci::cfg_w_to_o(width));
- if (res < 0)
- return res;
-
- ios << value;
- return L4_EOK;
-}
-
-int
-VPci_root::irq_enable(L4::Ipc::Iostream &ios)
-{
-#if 0
- l4_uint32_t bus;
- l4_uint32_t devfn;
- int pin;
-
- ios >> bus >> devfn >> pin;
- // printf("get IRQ for %02x:%02x.%x: pin INT%c\n", bus, devfn >> 16, devfn & 0xffff, pin + 'A');
- struct acpica_pci_irq *irq = 0;
- int res = acpica_pci_irq_find(0, bus, devfn >> 16, pin, &irq);
- if (res < 0)
- {
- ios << (int)-1;
- return res;
- }
-
- if (!irq)
- {
- ios << (int)-1;
- return -L4_EINVAL;
- }
-
- ios << irq->irq << irq->trigger << irq->polarity;
-#endif
- return L4_EOK;
-}
-
-int
-VPci_root::cfg_write(L4::Ipc::Iostream &ios)
-{
- l4_uint32_t bus;
- l4_uint32_t devfn;
- l4_uint32_t reg;
- l4_uint32_t value;
- l4_uint32_t width;
-
- ios >> bus >> devfn >> reg >> value >> width;
-
- int res = pci_root_bridge(0)->cfg_write(bus, devfn, reg, value, Pci::cfg_w_to_o(width));
- if (res < 0)
- return res;
-
- return L4_EOK;
-}
-
-int
-VPci_root::vbus_dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- switch (func)
- {
- case 0: return cfg_read(ios);
- case 1: return cfg_write(ios);
- case 2: return irq_enable(ios);
- default: return -L4_ENOSYS;
- }
-}
-
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "vpci.h"
-#include "vpci_pci_bridge.h"
-#include "vbus_factory.h"
-
-namespace Vi {
-
-/**
- * \brief A virtual Host-to-PCI bridge.
- */
-class Pci_vroot : public Pci_bridge, public Dev_feature
-{
-public:
-
- explicit Pci_vroot();
-
- int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
-
- ~Pci_vroot() {}
-
- char const *hid() const
- { return "PNP0A03"; }
-
- void set_host(Device *d) { _host = d; }
- Device *host() const { return _host; }
-
-private:
- Device *_host;
-
-public:
- int cfg_read(L4::Ipc::Iostream &ios);
- int cfg_write(L4::Ipc::Iostream &ios);
- int irq_enable(L4::Ipc::Iostream &ios);
- bool match_hw_feature(const Hw::Dev_feature*) const
- { return false; }
-};
-
-// -----------------------------------------------------------------------
-// Virtual PCI root bridge with identity mapping of phys devices
-// -----------------------------------------------------------------------
-
-
-class Pci_vroot_id : public Pci_vroot
-{
-public:
- void add_child(Device *d);
-
-};
-
-
-
-// -------------------------------------------------------------------
-// Virtual PCI Root bridge
-// -------------------------------------------------------------------
-
-Pci_vroot::Pci_vroot() : Pci_bridge()
-{
- add_feature(this);
- _subordinate = 100;
-}
-
-int
-Pci_vroot::cfg_read(L4::Ipc::Iostream &ios)
-{
- l4_uint32_t bus;
- l4_uint32_t devfn;
- l4_uint32_t reg;
- l4_uint32_t value = 0;
- l4_uint32_t width;
-
- ios >> bus >> devfn >> reg >> width;
- value = ~0U >> (32 - width);
-
- //printf("cfg read: %02x:%02x.%1x: reg=%x w=%d\n", bus, devfn >> 16, devfn & 0xffff, reg, width);
-
- if ((devfn >> 16) >= 32 || (devfn & 0xffff) >= 8)
- {
- ios << value;
- return L4_EOK;
- }
-
- Pci_dev *d = 0;
- child_dev(bus, (devfn >> 16), (devfn & 0xffff), &d);
-
- if (!d)
- {
- ios << value;
- return L4_EOK;
- }
-
- int res = d->cfg_read(reg, &value, Hw::Pci::cfg_w_to_o(width));
-
- if (res < 0)
- return res;
-
- //printf(" value=%x\n", value);
- ios << value;
- return L4_EOK;
-}
-int
-Pci_vroot::irq_enable(L4::Ipc::Iostream &ios)
-{
- l4_uint32_t bus;
- l4_uint32_t devfn;
-
- ios >> bus >> devfn;
-
- // printf("irq enable: %02x:%02x.%1x: pin=%d\n", bus, devfn >> 16, devfn & 0xffff, pin);
-
- if ((devfn >> 16) >= 32 || (devfn & 0xffff) >= 8)
- {
- ios << (int)-1;
- return L4_EOK;
- }
-
- Pci_dev *d = 0;
- child_dev(bus, (devfn >> 16), (devfn & 0xffff), &d);
- // printf("dev = %p\n", d);
- if (!d)
- {
- ios << (int)-1;
- return L4_EOK;
- }
-
- Pci_dev::Irq_info info;
- int res = d->irq_enable(&info);
- if (res < 0)
- {
- ios << (int)-1;
- return res;
- }
-
- // printf(" irq = %d\n", info.irq);
- ios << info.irq << info.trigger << info.polarity;
- return L4_EOK;
-}
-
-int
-Pci_vroot::cfg_write(L4::Ipc::Iostream &ios)
-{
- l4_uint32_t bus;
- l4_uint32_t devfn;
- l4_uint32_t reg;
- l4_uint32_t value;
- l4_uint32_t width;
-
- ios >> bus >> devfn >> reg >> value >> width;
- // printf("cfg write: %02x:%02x.%1x: reg=%x w=%x v=%08x\n", bus, devfn >> 16, devfn & 0xffff, reg, width, value);
-
- if ((devfn >> 16) >= 32 || (devfn & 0xffff) >= 8)
- return L4_EOK;
-
- Pci_dev *d = 0;
- child_dev(bus, (devfn >> 16), (devfn & 0xffff), &d);
-
- if (!d)
- return L4_EOK;
-
- return d->cfg_write(reg, value, Hw::Pci::cfg_w_to_o(width));
-}
-
-int
-Pci_vroot::dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios)
-{
- switch (func)
- {
- case 0: return cfg_read(ios);
- case 1: return cfg_write(ios);
- case 2: return irq_enable(ios);
- default: return -L4_ENOSYS;
- }
-}
-
-
-void
-Pci_vroot_id::add_child(Device *d)
-{
- Pci_dev *vp = d->find_feature<Pci_dev>();
-
- // hm, also here, drom non PCI devices
- if (!vp)
- return;
-
- if (Pci_proxy_dev *proxy = dynamic_cast<Pci_proxy_dev*>(vp))
- {
- Pci_pci_bridge_basic const *hw_br
- = dynamic_cast<Pci_pci_bridge_basic const *>(proxy->hwf()->bus());
-
- l4_uint32_t hwadr = proxy->hwf()->host()->adr();
- // printf("VPCI: add proxy PCI device %p (hwbr=%p)\n", proxy, hw_br);
- unsigned dn = (hwadr >> 16) & (Bus::Devs-1);
- unsigned fn = hwadr & (Dev::Fns-1);
-
- if (!hw_br)
- {
- // MUST be a device on the root PCI bus
- _bus.dev(dn)->fn(fn, vp);
- Device::add_child(d);
- return;
- }
-
- Pci_bridge *sw_br = find_bridge(hw_br->num);
- if (!sw_br)
- {
- Pci_to_pci_bridge *b = new Pci_to_pci_bridge();
- sw_br = b;
- sw_br->primary(hw_br->pri);
- sw_br->secondary(hw_br->num);
- sw_br->subordinate(hw_br->subordinate);
-
- unsigned dn = (hw_br->host()->adr() >> 16) & (Bus::Devs-1);
- unsigned fn = hw_br->host()->adr() & (Dev::Fns-1);
- _bus.dev(dn)->fn(fn, b);
- Device::add_child(b);
- }
-
- sw_br->add_child_fixed(d, vp, dn, fn);
- return;
- }
- else
- {
- _bus.add_fn(vp);
- Device::add_child(d);
- }
-}
-
-
-
-static Dev_factory_t<Pci_vroot> __pci_root_factory("PCI_bus");
-static Dev_factory_t<Pci_vroot_id> __pci_root_id_factory("PCI_bus_ident");
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#include "vproxy_dev.h"
-#include "vbus_factory.h"
-
-namespace Vi {
-
-Proxy_dev::Proxy_dev(Hw::Device *d)
-: _hwd(d)
-{
- // suck features from real dev
- for (Hw::Device::Feature_list::const_iterator i = d->features()->begin();
- i != d->features()->end(); ++i)
- {
- Dev_feature *vf = Feature_factory::create(*i);
- if (vf)
- add_feature(vf);
- }
-
- // suck resources from our real dev
- for (Resource_list::const_iterator i = d->resources()->begin();
- i != d->resources()->end(); ++i)
- {
- if (!*i)
- continue;
-
- if ((*i)->disabled())
- continue;
-
- Resource *vr = Resource_factory::create(*i, false);
- if (!vr)
- vr = *i;
-
- add_resource(vr);
- }
-}
-
-namespace {
- static Dev_factory_t<Proxy_dev, Hw::Device> __ghwdf;
-}
-
-}
+++ /dev/null
-/*
- * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
- * economic rights: Technische Universität Dresden (Germany)
- *
- * This file is part of TUD:OS and distributed under the terms of the
- * GNU General Public License 2.
- * Please see the COPYING-GPL-2 file for details.
- */
-
-#pragma once
-
-#include "vdevice.h"
-#include "hw_device.h"
-
-class Tagged_parameter;
-
-namespace Vi {
-
-class Proxy_dev : public Device
-{
-public:
- explicit Proxy_dev(Hw::Device *d);
-
- char const *hid() const { return _hwd->hid(); }
-private:
- Hw::Device *_hwd;
-};
-
-}
+++ /dev/null
-LIB_NAME := libbsd
-LIB_VERSION_MAJOR := 0
-LIB_VERSION_MINOR := 1
-LIB_VERSION_MICRO := 4
-LIB_VERSION := $(LIB_VERSION_MAJOR).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)
-
-LIB_PKGCONFIG := $(LIB_NAME).pc
-LIB_STATIC := $(LIB_NAME).a
-LIB_SHARED_SO := $(LIB_NAME).so
-LIB_SONAME := $(LIB_SHARED_SO).$(LIB_VERSION_MAJOR)
-LIB_SHARED := $(LIB_SONAME).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)
-
-TAR_NAME := $(LIB_NAME)-$(LIB_VERSION)
-TAR_FILE := $(TAR_NAME).tar.gz
-
-LIB_DIST := \
- Makefile \
- README \
- ChangeLog \
- Versions \
- $(LIB_PKGCONFIG).in
-
-LIB_SRCS := \
- arc4random.c \
- bsd_getopt.c \
- err.c \
- fgetln.c \
- heapsort.c \
- humanize_number.c \
- inet_net_pton.c \
- hash/md5.c hash/md5hl.c \
- setmode.c \
- strmode.c \
- strlcat.c strlcpy.c \
- fmtcheck.c \
- nlist.c \
- progname.c \
- vis.c unvis.c
-LIB_SRCS := $(patsubst %,src/%,$(LIB_SRCS))
-
-LIB_GEN_SRCS := \
- man/md5.3bsd \
- src/hash/md5hl.c
-
-LIB_INCLUDES := \
- bsd/err.h \
- bsd/getopt.h \
- bsd/inet.h \
- bsd/ip_icmp.h \
- bsd/random.h \
- bsd/queue.h \
- bsd/md5.h \
- bsd/string.h \
- bsd/bsd.h \
- bsd/cdefs.h \
- bsd/stdlib.h \
- nlist.h \
- vis.h \
- libutil.h
-
-LIB_MANS := \
- arc4random.3 \
- arc4random_addrandom.3 \
- arc4random_stir.3 \
- strlcpy.3 \
- strlcat.3 \
- fgetln.3 \
- humanize_number.3 \
- fmtcheck.3 \
- nlist.3 \
- setmode.3 \
- getmode.3 \
- strmode.3 \
- md5.3bsd
-LIB_MANS := $(patsubst %,man/%,$(LIB_MANS))
-
-LIB_STATIC_OBJS := $(LIB_SRCS:%.c=%.o)
-LIB_SHARED_OBJS := $(LIB_SRCS:%.c=%.lo)
-
-# Set default value for compilation
-CFLAGS ?= -g -Wall -Wextra -Wno-unused-variable
-
-MK_CFLAGS := -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
-
-prefix = /usr
-exec_prefix =
-libdir = ${exec_prefix}/lib
-usrlibdir = ${prefix}/lib
-includedir = ${prefix}/include
-pkgconfigdir = ${usrlibdir}/pkgconfig
-mandir = ${prefix}/share/man
-
-.PHONY: libs
-libs: $(LIB_STATIC) $(LIB_SHARED_SO) $(LIB_PKGCONFIG)
-
-.PHONY: man
-man: $(LIB_MANS)
-
-%.lo: %.c
- $(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -DPIC -fPIC -c $<
-
-%.o: %.c
- $(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -c $<
-
-man/md5.3bsd: man/mdX.3
- sed -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g' $< > $@
-
-src/hash/md5hl.c: src/hash/helper.c
- sed -e 's:hashinc:bsd/md5.h:g' -e 's:HASH:MD5:g' $< > $@
-
-$(LIB_PKGCONFIG): $(LIB_PKGCONFIG).in
- sed -e 's:@VERSION@:$(LIB_VERSION):' \
- -e 's:@prefix@:$(value prefix):' \
- -e 's:@exec_prefix@:$(value exec_prefix):' \
- -e 's:@libdir@:$(value usrlibdir):' \
- -e 's:@includedir@:$(value includedir):' \
- $< > $@
-
-$(LIB_STATIC): $(LIB_STATIC_OBJS)
- ar rcs $@ $^
-
-$(LIB_SHARED_SO): $(LIB_SONAME)
- ln -fs $^ $@
-
-$(LIB_SONAME): $(LIB_SHARED)
- ln -fs $^ $@
-
-$(LIB_SHARED): $(LIB_SHARED_OBJS)
- gcc -shared \
- -Wl,-soname -Wl,$(LIB_SONAME) \
- -Wl,--version-script=Versions \
- -o $@ $^
-
-.PHONY: ChangeLog
-ChangeLog:
- -git log --stat -C >$@
-
-.PHONY: dist
-dist: ChangeLog
- mkdir $(TAR_NAME)
- cp -a include src man $(LIB_DIST) $(TAR_NAME)
- tar czf $(TAR_FILE) --exclude=.gitignore $(TAR_NAME)
- rm -rf $(TAR_NAME)
- gpg -a -b $(TAR_FILE)
-
-.PHONY: install
-install: libs man
- mkdir -p $(DESTDIR)/$(libdir)
- mkdir -p $(DESTDIR)/$(usrlibdir)
- mkdir -p $(DESTDIR)/$(includedir)/bsd/
- mkdir -p $(DESTDIR)/$(mandir)/man3
- mkdir -p $(DESTDIR)/$(pkgconfigdir)
- install -m644 $(LIB_STATIC) $(DESTDIR)/$(usrlibdir)
- install -m644 $(LIB_SHARED) $(DESTDIR)/$(libdir)
- for i in $(LIB_INCLUDES); do \
- install -m644 include/$$i $(DESTDIR)/$(includedir)/$$i; \
- done
- install -m644 $(LIB_MANS) $(DESTDIR)/$(mandir)/man3
- install -m644 $(LIB_PKGCONFIG) $(DESTDIR)/$(pkgconfigdir)
-ifeq ($(libdir),$(usrlibdir))
- # If both dirs are the same, do a relative symlink.
- ln -sf $(LIB_SHARED) $(DESTDIR)/$(usrlibdir)/$(LIB_SHARED_SO)
-else
- # Otherwise, do an absolute one.
- ln -sf $(libdir)/$(LIB_SHARED) $(DESTDIR)/$(usrlibdir)/$(LIB_SHARED_SO)
-endif
- ln -sf $(LIB_SHARED) $(DESTDIR)/$(libdir)/$(LIB_SONAME)
-
-.PHONY: clean
-clean:
- rm -f $(LIB_PKGCONFIG)
- rm -f $(LIB_GEN_SRCS)
- rm -f $(LIB_STATIC_OBJS)
- rm -f $(LIB_STATIC)
- rm -f $(LIB_SHARED_OBJS)
- rm -f $(LIB_SHARED) $(LIB_SONAME) $(LIB_SHARED_SO)
-
+++ /dev/null
-LIBBSD_0.0 {
- global:
- arc4random;
- arc4random_stir;
- arc4random_addrandom;
- bsd_getopt; optreset;
- errc; warnc; verrc; vwarnc;
- fgetln;
- fgetwln;
- fmtcheck;
- heapsort;
- humanize_number;
- inet_net_pton;
-
- getprogname; setprogname;
- strlcpy;
- strlcat;
-
- setmode;
- getmode;
-
- vis; strvis; strvisx;
- unvis; strunvis; strunvisx;
- MD5Init;
- MD5Update;
- MD5Pad;
- MD5Final;
- MD5Transform;
- MD5End;
- MD5File;
- MD5FileChunk;
- MD5Data;
-
- local:
- *;
-};
-
-LIBBSD_0.1 {
- strmode;
-
- __fdnlist; /* Private symbol, but libkvm uses it. */
- nlist;
-} LIBBSD_0.0;
-
+++ /dev/null
-/*
- * Copyright © 2004, 2005, 2006, 2009 Guillem Jover
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBBSD_CDEFS_H
-#define LIBBSD_CDEFS_H
-
-#include <sys/cdefs.h>
-
-#ifndef setproctitle
-# define setproctitle(fmt, args...)
-#endif
-
-#ifndef __dead2
-# define __dead2
-#endif
-
-/* Linux headers define a struct with a member names __unused.
- * Disable for now. */
-#if 0
-#ifndef __unused
-# ifdef __GNUC__
-# define __unused __attribute__((unused))
-# else
-# define __unused
-# endif
-#endif
-#endif
-
-#ifndef __printflike
-# ifdef __GNUC__
-# define __printflike(x, y) __attribute((format(printf, (x), (y))))
-# else
-# define __printflike(x, y)
-# endif
-#endif
-
-#ifndef __bounded__
-# define __bounded__(x, y, z)
-#endif
-
-#ifndef __RCSID
-# define __RCSID(x)
-#endif
-
-#ifndef __FBSDID
-# define __FBSDID(x)
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright © 2008, 2009 Guillem Jover
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBBSD_INET_H
-#define LIBBSD_INET_H
-
-#include <sys/cdefs.h>
-#include <stddef.h>
-
-__BEGIN_DECLS
-int inet_net_pton(int af, const char *src, void *dst, siez_t size);
-__END_DECLS
-
-#endif
-
+++ /dev/null
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.22 2004/04/07 20:46:13 imp Exp $
- */
-
-#ifndef _NETINET_IP_ICMP_H_
-#define _NETINET_IP_ICMP_H_
-
-#include <sys/types.h> /* u_int32_t, u_char */
-#include <netinet/in.h> /* in_addr */
-#include <netinet/in_systm.h> /* n_short */
-#include <netinet/ip.h> /* idi_ip */
-
-/*
- * Interface Control Message Protocol Definitions.
- * Per RFC 792, September 1981.
- */
-
-/*
- * Internal of an ICMP Router Advertisement
- */
-struct icmp_ra_addr {
- u_int32_t ira_addr;
- u_int32_t ira_preference;
-};
-
-/*
- * Structure of an icmp header.
- */
-struct icmp {
- u_char icmp_type; /* type of message, see below */
- u_char icmp_code; /* type sub code */
- u_short icmp_cksum; /* ones complement cksum of struct */
- union {
- u_char ih_pptr; /* ICMP_PARAMPROB */
- struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
- struct ih_idseq {
- n_short icd_id;
- n_short icd_seq;
- } ih_idseq;
- int ih_void;
-
- /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
- struct ih_pmtu {
- n_short ipm_void;
- n_short ipm_nextmtu;
- } ih_pmtu;
-
- struct ih_rtradv {
- u_char irt_num_addrs;
- u_char irt_wpa;
- u_int16_t irt_lifetime;
- } ih_rtradv;
- } icmp_hun;
-#define icmp_pptr icmp_hun.ih_pptr
-#define icmp_gwaddr icmp_hun.ih_gwaddr
-#define icmp_id icmp_hun.ih_idseq.icd_id
-#define icmp_seq icmp_hun.ih_idseq.icd_seq
-#define icmp_void icmp_hun.ih_void
-#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
-#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
-#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
-#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
-#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
- union {
- struct id_ts { /* ICMP Timestamp */
- n_time its_otime; /* Originate */
- n_time its_rtime; /* Receive */
- n_time its_ttime; /* Transmit */
- } id_ts;
- struct id_ip {
- struct ip idi_ip;
- /* options and then 64 bits of data */
- } id_ip;
- struct icmp_ra_addr id_radv;
- u_int32_t id_mask;
- char id_data[1];
- } icmp_dun;
-#define icmp_otime icmp_dun.id_ts.its_otime
-#define icmp_rtime icmp_dun.id_ts.its_rtime
-#define icmp_ttime icmp_dun.id_ts.its_ttime
-#define icmp_ip icmp_dun.id_ip.idi_ip
-#define icmp_radv icmp_dun.id_radv
-#define icmp_mask icmp_dun.id_mask
-#define icmp_data icmp_dun.id_data
-};
-
-/*
- * Lower bounds on packet lengths for various types.
- * For the error advice packets must first insure that the
- * packet is large enough to contain the returned ip header.
- * Only then can we do the check to see if 64 bits of packet
- * data have been returned, since we need to check the returned
- * ip header length.
- */
-#define ICMP_MINLEN 8 /* abs minimum */
-#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
-#define ICMP_MASKLEN 12 /* address mask */
-#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
-#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
- /* N.B.: must separately check that ip_hl >= 5 */
-
-/*
- * Definition of type and code field values.
- */
-#define ICMP_ECHOREPLY 0 /* echo reply */
-#define ICMP_UNREACH 3 /* dest unreachable, codes: */
-#define ICMP_UNREACH_NET 0 /* bad net */
-#define ICMP_UNREACH_HOST 1 /* bad host */
-#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
-#define ICMP_UNREACH_PORT 3 /* bad port */
-#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
-#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
-#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
-#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
-#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
-#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
-#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
-#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
-#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
-#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
-#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
-#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
-#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
-#define ICMP_REDIRECT 5 /* shorter route, codes: */
-#define ICMP_REDIRECT_NET 0 /* for network */
-#define ICMP_REDIRECT_HOST 1 /* for host */
-#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
-#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
-#define ICMP_ALTHOSTADDR 6 /* alternate host address */
-#define ICMP_ECHO 8 /* echo service */
-#define ICMP_ROUTERADVERT 9 /* router advertisement */
-#define ICMP_ROUTERADVERT_NORMAL 0 /* normal advertisement */
-#define ICMP_ROUTERADVERT_NOROUTE_COMMON 16 /* selective routing */
-#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
-#define ICMP_TIMXCEED 11 /* time exceeded, code: */
-#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
-#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
-#define ICMP_PARAMPROB 12 /* ip header bad */
-#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */
-#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
-#define ICMP_PARAMPROB_LENGTH 2 /* bad length */
-#define ICMP_TSTAMP 13 /* timestamp request */
-#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
-#define ICMP_IREQ 15 /* information request */
-#define ICMP_IREQREPLY 16 /* information reply */
-#define ICMP_MASKREQ 17 /* address mask request */
-#define ICMP_MASKREPLY 18 /* address mask reply */
-#define ICMP_TRACEROUTE 30 /* traceroute */
-#define ICMP_DATACONVERR 31 /* data conversion error */
-#define ICMP_MOBILE_REDIRECT 32 /* mobile host redirect */
-#define ICMP_IPV6_WHEREAREYOU 33 /* IPv6 where-are-you */
-#define ICMP_IPV6_IAMHERE 34 /* IPv6 i-am-here */
-#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */
-#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */
-#define ICMP_SKIP 39 /* SKIP */
-#define ICMP_PHOTURIS 40 /* Photuris */
-#define ICMP_PHOTURIS_UNKNOWN_INDEX 1 /* unknown sec index */
-#define ICMP_PHOTURIS_AUTH_FAILED 2 /* auth failed */
-#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */
-
-#define ICMP_MAXTYPE 40
-
-#define ICMP_INFOTYPE(type) \
- ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
- (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
- (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
- (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
- (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
-
-#ifdef _KERNEL
-void icmp_error(struct mbuf *, int, int, n_long, struct ifnet *);
-void icmp_input(struct mbuf *, int);
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- * $FreeBSD: src/sys/sys/queue.h,v 1.58 2004/04/07 04:19:49 imp Exp $
- */
-
-#ifndef _SYS_QUEUE_H
-#define _SYS_QUEUE_H
-
-#include <sys/cdefs.h>
-
-/*
- * This file defines four types of data structures: singly-linked lists,
- * singly-linked tail queues, lists and tail queues.
- *
- * A singly-linked list is headed by a single forward pointer. The elements
- * are singly linked for minimum space and pointer manipulation overhead at
- * the expense of O(n) removal for arbitrary elements. New elements can be
- * added to the list after an existing element or at the head of the list.
- * Elements being removed from the head of the list should use the explicit
- * macro for this purpose for optimum efficiency. A singly-linked list may
- * only be traversed in the forward direction. Singly-linked lists are ideal
- * for applications with large datasets and few or no removals or for
- * implementing a LIFO queue.
- *
- * A singly-linked tail queue is headed by a pair of pointers, one to the
- * head of the list and the other to the tail of the list. The elements are
- * singly linked for minimum space and pointer manipulation overhead at the
- * expense of O(n) removal for arbitrary elements. New elements can be added
- * to the list after an existing element, at the head of the list, or at the
- * end of the list. Elements being removed from the head of the tail queue
- * should use the explicit macro for this purpose for optimum efficiency.
- * A singly-linked tail queue may only be traversed in the forward direction.
- * Singly-linked tail queues are ideal for applications with large datasets
- * and few or no removals or for implementing a FIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- *
- *
- * SLIST LIST STAILQ TAILQ
- * _HEAD + + + +
- * _HEAD_INITIALIZER + + + +
- * _ENTRY + + + +
- * _INIT + + + +
- * _EMPTY + + + +
- * _FIRST + + + +
- * _NEXT + + + +
- * _PREV - - - +
- * _LAST - - + +
- * _FOREACH + + + +
- * _FOREACH_SAFE + + + +
- * _FOREACH_REVERSE - - - +
- * _FOREACH_REVERSE_SAFE - - - +
- * _INSERT_HEAD + + + +
- * _INSERT_BEFORE - + - +
- * _INSERT_AFTER + + + +
- * _INSERT_TAIL - - + +
- * _CONCAT - - + +
- * _REMOVE_HEAD + - + -
- * _REMOVE + + + +
- *
- */
-#define QUEUE_MACRO_DEBUG 0
-#if QUEUE_MACRO_DEBUG
-/* Store the last 2 places the queue element or head was altered */
-struct qm_trace {
- char * lastfile;
- int lastline;
- char * prevfile;
- int prevline;
-};
-
-#define TRACEBUF struct qm_trace trace;
-#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
-
-#define QMD_TRACE_HEAD(head) do { \
- (head)->trace.prevline = (head)->trace.lastline; \
- (head)->trace.prevfile = (head)->trace.lastfile; \
- (head)->trace.lastline = __LINE__; \
- (head)->trace.lastfile = __FILE__; \
-} while (0)
-
-#define QMD_TRACE_ELEM(elem) do { \
- (elem)->trace.prevline = (elem)->trace.lastline; \
- (elem)->trace.prevfile = (elem)->trace.lastfile; \
- (elem)->trace.lastline = __LINE__; \
- (elem)->trace.lastfile = __FILE__; \
-} while (0)
-
-#else
-#define QMD_TRACE_ELEM(elem)
-#define QMD_TRACE_HEAD(head)
-#define TRACEBUF
-#define TRASHIT(x)
-#endif /* QUEUE_MACRO_DEBUG */
-
-/*
- * Singly-linked List declarations.
- */
-#define SLIST_HEAD(name, type) \
-struct name { \
- struct type *slh_first; /* first element */ \
-}
-
-#define SLIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define SLIST_ENTRY(type) \
-struct { \
- struct type *sle_next; /* next element */ \
-}
-
-/*
- * Singly-linked List functions.
- */
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-
-#define SLIST_FIRST(head) ((head)->slh_first)
-
-#define SLIST_FOREACH(var, head, field) \
- for ((var) = SLIST_FIRST((head)); \
- (var); \
- (var) = SLIST_NEXT((var), field))
-
-#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = SLIST_FIRST((head)); \
- (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
- for ((varp) = &SLIST_FIRST((head)); \
- ((var) = *(varp)) != NULL; \
- (varp) = &SLIST_NEXT((var), field))
-
-#define SLIST_INIT(head) do { \
- SLIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
- SLIST_NEXT((slistelm), field) = (elm); \
-} while (0)
-
-#define SLIST_INSERT_HEAD(head, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
- SLIST_FIRST((head)) = (elm); \
-} while (0)
-
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-
-#define SLIST_REMOVE(head, elm, type, field) do { \
- if (SLIST_FIRST((head)) == (elm)) { \
- SLIST_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = SLIST_FIRST((head)); \
- while (SLIST_NEXT(curelm, field) != (elm)) \
- curelm = SLIST_NEXT(curelm, field); \
- SLIST_NEXT(curelm, field) = \
- SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
- } \
-} while (0)
-
-#define SLIST_REMOVE_HEAD(head, field) do { \
- SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
-} while (0)
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define STAILQ_HEAD(name, type) \
-struct name { \
- struct type *stqh_first;/* first element */ \
- struct type **stqh_last;/* addr of last next element */ \
-}
-
-#define STAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).stqh_first }
-
-#define STAILQ_ENTRY(type) \
-struct { \
- struct type *stqe_next; /* next element */ \
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define STAILQ_CONCAT(head1, head2) do { \
- if (!STAILQ_EMPTY((head2))) { \
- *(head1)->stqh_last = (head2)->stqh_first; \
- (head1)->stqh_last = (head2)->stqh_last; \
- STAILQ_INIT((head2)); \
- } \
-} while (0)
-
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-
-#define STAILQ_FOREACH(var, head, field) \
- for((var) = STAILQ_FIRST((head)); \
- (var); \
- (var) = STAILQ_NEXT((var), field))
-
-
-#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = STAILQ_FIRST((head)); \
- (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define STAILQ_INIT(head) do { \
- STAILQ_FIRST((head)) = NULL; \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_NEXT((tqelm), field) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_FIRST((head)) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- STAILQ_NEXT((elm), field) = NULL; \
- *(head)->stqh_last = (elm); \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
-} while (0)
-
-#define STAILQ_LAST(head, type, field) \
- (STAILQ_EMPTY((head)) ? \
- NULL : \
- ((struct type *)(void *) \
- ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
-
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-
-#define STAILQ_REMOVE(head, elm, type, field) do { \
- if (STAILQ_FIRST((head)) == (elm)) { \
- STAILQ_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = STAILQ_FIRST((head)); \
- while (STAILQ_NEXT(curelm, field) != (elm)) \
- curelm = STAILQ_NEXT(curelm, field); \
- if ((STAILQ_NEXT(curelm, field) = \
- STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
- } \
-} while (0)
-
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if ((STAILQ_FIRST((head)) = \
- STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \
- if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-/*
- * List declarations.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-
-#define LIST_FIRST(head) ((head)->lh_first)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = LIST_FIRST((head)); \
- (var); \
- (var) = LIST_NEXT((var), field))
-
-#define LIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = LIST_FIRST((head)); \
- (var) && ((tvar) = LIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define LIST_INIT(head) do { \
- LIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
- LIST_NEXT((listelm), field)->field.le_prev = \
- &LIST_NEXT((elm), field); \
- LIST_NEXT((listelm), field) = (elm); \
- (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
-} while (0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- LIST_NEXT((elm), field) = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
-} while (0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
- LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
- LIST_FIRST((head)) = (elm); \
- (elm)->field.le_prev = &LIST_FIRST((head)); \
-} while (0)
-
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
-
-#define LIST_REMOVE(elm, field) do { \
- if (LIST_NEXT((elm), field) != NULL) \
- LIST_NEXT((elm), field)->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = LIST_NEXT((elm), field); \
-} while (0)
-
-/*
- * Tail queue declarations.
- */
-#define TAILQ_HEAD(name, type) \
-struct name { \
- struct type *tqh_first; /* first element */ \
- struct type **tqh_last; /* addr of last next element */ \
- TRACEBUF \
-}
-
-#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
-
-#define TAILQ_ENTRY(type) \
-struct { \
- struct type *tqe_next; /* next element */ \
- struct type **tqe_prev; /* address of previous next element */ \
- TRACEBUF \
-}
-
-/*
- * Tail queue functions.
- */
-#define TAILQ_CONCAT(head1, head2, field) do { \
- if (!TAILQ_EMPTY(head2)) { \
- *(head1)->tqh_last = (head2)->tqh_first; \
- (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
- (head1)->tqh_last = (head2)->tqh_last; \
- TAILQ_INIT((head2)); \
- QMD_TRACE_HEAD(head1); \
- QMD_TRACE_HEAD(head2); \
- } \
-} while (0)
-
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = TAILQ_FIRST((head)); \
- (var); \
- (var) = TAILQ_NEXT((var), field))
-
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var); \
- (var) = TAILQ_PREV((var), headname, field))
-
-#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
- (var) = (tvar))
-
-#define TAILQ_INIT(head) do { \
- TAILQ_FIRST((head)) = NULL; \
- (head)->tqh_last = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
-} while (0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else { \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- } \
- TAILQ_NEXT((listelm), field) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- TAILQ_NEXT((elm), field) = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
-
-#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
- TAILQ_FIRST((head))->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- TAILQ_FIRST((head)) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- TAILQ_NEXT((elm), field) = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-#define TAILQ_REMOVE(head, elm, field) do { \
- if ((TAILQ_NEXT((elm), field)) != NULL) \
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else { \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- QMD_TRACE_HEAD(head); \
- } \
- *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
- TRASHIT((elm)->field.tqe_next); \
- TRASHIT((elm)->field.tqe_prev); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-
-#ifdef _KERNEL
-
-/*
- * XXX insque() and remque() are an old way of handling certain queues.
- * They bogusly assumes that all queue heads look alike.
- */
-
-struct quehead {
- struct quehead *qh_link;
- struct quehead *qh_rlink;
-};
-
-#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-
-static __inline void
-insque(void *a, void *b)
-{
- struct quehead *element = (struct quehead *)a,
- *head = (struct quehead *)b;
-
- element->qh_link = head->qh_link;
- element->qh_rlink = head;
- head->qh_link = element;
- element->qh_link->qh_rlink = element;
-}
-
-static __inline void
-remque(void *a)
-{
- struct quehead *element = (struct quehead *)a;
-
- element->qh_link->qh_rlink = element->qh_rlink;
- element->qh_rlink->qh_link = element->qh_link;
- element->qh_rlink = 0;
-}
-
-#else /* !(__GNUC__ || __INTEL_COMPILER) */
-
-void insque(void *a, void *b);
-void remque(void *a);
-
-#endif /* __GNUC__ || __INTEL_COMPILER */
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_QUEUE_H */
+++ /dev/null
-/*
- * Copyright © 2004, 2005, 2009 Guillem Jover
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBBSD_RANDOM_H
-#define LIBBSD_RANDOM_H
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-__BEGIN_DECLS
-u_int32_t arc4random();
-void arc4random_stir();
-void arc4random_addrandom(u_char *dat, int datlen);
-__END_DECLS
-
-#endif
-
+++ /dev/null
-/*
- * Copyright (c) 1996 Peter Wemm <peter@FreeBSD.org>.
- * All rights reserved.
- * Copyright (c) 2002 Networks Associates Technology, Inc.
- * All rights reserved.
- *
- * Portions of this software were developed for the FreeBSD Project by
- * ThinkSec AS and NAI Labs, the Security Research Division of Network
- * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
- * ("CBOSS"), as part of the DARPA CHATS research program.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, is permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD: src/lib/libutil/libutil.h,v 1.47 2008/04/23 00:49:12 scf Exp $
- */
-
-#ifndef _LIBUTIL_H_
-#define _LIBUTIL_H_
-
-#include <features.h>
-#include <sys/types.h>
-
-
-__BEGIN_DECLS
-int humanize_number(char *buf, size_t len, int64_t bytes,
- const char *suffix, int scale, int flags);
-__END_DECLS
-
-/* humanize_number(3) */
-#define HN_DECIMAL 0x01
-#define HN_NOSPACE 0x02
-#define HN_B 0x04
-#define HN_DIVISOR_1000 0x08
-
-#define HN_GETSCALE 0x10
-#define HN_AUTOSCALE 0x20
-
-#endif /* !_LIBUTIL_H_ */
+++ /dev/null
-/*
- * Copyright © 2009 Guillem Jover
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBBSD_NLIST_H
-#define LIBBSD_NLIST_H
-
-#include <sys/cdefs.h>
-#include <a.out.h>
-
-__BEGIN_DECLS
-extern int nlist(const char *filename, struct nlist *list);
-__END_DECLS
-
-#endif
-
+++ /dev/null
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)vis.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD: src/include/vis.h,v 1.11 2003/10/30 10:40:49 phk Exp $
- */
-
-#ifndef _VIS_H_
-#define _VIS_H_
-
-#include <sys/types.h>
-
-/*
- * to select alternate encoding format
- */
-#define VIS_OCTAL 0x01 /* use octal \ddd format */
-#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropriate */
-
-/*
- * to alter set of characters encoded (default is to encode all
- * non-graphic except space, tab, and newline).
- */
-#define VIS_SP 0x04 /* also encode space */
-#define VIS_TAB 0x08 /* also encode tab */
-#define VIS_NL 0x10 /* also encode newline */
-#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
-#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
-
-/*
- * other
- */
-#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
-#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
-#define VIS_GLOB 0x100 /* encode glob(3) magics */
-
-/*
- * unvis return codes
- */
-#define UNVIS_VALID 1 /* character valid */
-#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
-#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
-#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
-#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
-
-/*
- * unvis flags
- */
-#define UNVIS_END 1 /* no more characters */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-char *vis(char *, int, int, int);
-int strvis(char *, const char *, int);
-int strvisx(char *, const char *, size_t, int);
-int strunvis(char *, const char *);
-int strunvisx(char *, const char *, int);
-int unvis(char *, int, int *, int);
-__END_DECLS
-
-#endif /* !_VIS_H_ */
+++ /dev/null
-.\"
-.\" ----------------------------------------------------------------------------
-.\" "THE BEER-WARE LICENSE" (Revision 42):
-.\" <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
-.\" can do whatever you want with this stuff. If we meet some day, and you think
-.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-.\" ----------------------------------------------------------------------------
-.\"
-.\" $MirOS: src/lib/libc/hash/mdX.3,v 1.4 2007/05/07 16:15:56 tg Exp $
-.\" $OpenBSD: mdX.3,v 1.9 2004/08/24 20:10:33 millert Exp $
-.\"
-.Dd April 29, 2004
-.Dt MDX 3
-.Os
-.Sh NAME
-.Nm MDXInit ,
-.Nm MDXUpdate ,
-.Nm MDXPad ,
-.Nm MDXFinal ,
-.Nm MDXTransform ,
-.Nm MDXEnd ,
-.Nm MDXFile ,
-.Nm MDXFileChunk ,
-.Nm MDXData
-.Nd calculate the RSA Data Security, Inc., ``MDX'' message digest
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <mdX.h>
-.Ft void
-.Fn MDXInit "MDX_CTX *context"
-.Ft void
-.Fn MDXUpdate "MDX_CTX *context" "const u_int8_t *data" "size_t len"
-.Ft void
-.Fn MDXPad "MDX_CTX *context"
-.Ft void
-.Fn MDXFinal "u_int8_t digest[MDX_DIGEST_LENGTH]" "MDX_CTX *context"
-.Ft void
-.Fn MDXTransform "u_int32_t state[4]" "u_int8_t block[MDX_BLOCK_LENGTH]"
-.Ft "char *"
-.Fn MDXEnd "MDX_CTX *context" "char *buf"
-.Ft "char *"
-.Fn MDXFile "const char *filename" "char *buf"
-.Ft "char *"
-.Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
-.Ft "char *"
-.Fn MDXData "const u_int8_t *data" "size_t len" "char *buf"
-.Sh DESCRIPTION
-The MDX functions calculate a 128-bit cryptographic checksum (digest)
-for any number of input bytes.
-A cryptographic checksum is a one-way
-hash-function, that is, you cannot find (except by exhaustive search)
-the input corresponding to a particular output.
-This net result is a
-.Dq fingerprint
-of the input-data, which doesn't disclose the actual input.
-.Pp
-MD4 has been broken; it should only be used where necessary for
-backward compatibility.
-MD5 has not yet (1999-02-11) been broken, but recent attacks have cast
-some doubt on its security properties.
-The attacks on both MD4 and MD5
-are both in the nature of finding
-.Dq collisions
-\- that is, multiple
-inputs which hash to the same value; it is still unlikely for an attacker
-to be able to determine the exact original input given a hash value.
-.Pp
-The
-.Fn MDXInit ,
-.Fn MDXUpdate ,
-and
-.Fn MDXFinal
-functions are the core functions.
-Allocate an MDX_CTX, initialize it with
-.Fn MDXInit ,
-run over the data with
-.Fn MDXUpdate ,
-and finally extract the result using
-.Fn MDXFinal .
-.Pp
-The
-.Fn MDXPad
-function can be used to apply padding to the message digest as in
-.Fn MDXFinal ,
-but the current context can still be used with
-.Fn MDXUpdate .
-.Pp
-The
-.Fn MDXTransform
-function is used by
-.Fn MDXUpdate
-to hash 512-bit blocks and forms the core of the algorithm.
-Most programs should use the interface provided by
-.Fn MDXInit ,
-.Fn MDXUpdate
-and
-.Fn MDXFinal
-instead of calling
-.Fn MDXTransform
-directly.
-.Pp
-.Fn MDXEnd
-is a wrapper for
-.Fn MDXFinal
-which converts the return value to an MDX_DIGEST_STRING_LENGTH-character
-(including the terminating '\e0')
-.Tn ASCII
-string which represents the 128 bits in hexadecimal.
-.Pp
-.Fn MDXFile
-calculates the digest of a file, and uses
-.Fn MDXEnd
-to return the result.
-If the file cannot be opened, a null pointer is returned.
-.Pp
-.Fn MDXFileChunk
-behaves like
-.Fn MDXFile
-but calculates the digest only for that portion of the file starting at
-.Fa offset
-and continuing for
-.Fa length
-bytes or until end of file is reached, whichever comes first.
-A zero
-.Fa length
-can be specified to read until end of file.
-A negative
-.Fa length
-or
-.Fa offset
-will be ignored.
-.Fn MDXData
-calculates the digest of a chunk of data in memory, and uses
-.Fn MDXEnd
-to return the result.
-.Pp
-When using
-.Fn MDXEnd ,
-.Fn MDXFile ,
-.Fn MDXFileChunk ,
-or
-.Fn MDXData ,
-the
-.Ar buf
-argument can be a null pointer, in which case the returned string
-is allocated with
-.Xr malloc 3
-and subsequently must be explicitly deallocated using
-.Xr free 3
-after use.
-If the
-.Ar buf
-argument is non-null it must point to at least MDX_DIGEST_STRING_LENGTH
-characters of buffer space.
-.Sh SEE ALSO
-.Xr cksum 1 ,
-.Xr md5 1 ,
-.Xr adler32 3 ,
-.Xr mdY 3 ,
-.Xr rmd160 3 ,
-.Xr sfv 3 ,
-.Xr sha1 3 ,
-.Xr sha2 3 ,
-.Xr suma 3 ,
-.Xr tiger 3 ,
-.Xr whirlpool 3
-.Rs
-.%A R. Rivest
-.%T The MD4 Message-Digest Algorithm
-.%O RFC 1186
-.Re
-.Rs
-.%A R. Rivest
-.%T The MD5 Message-Digest Algorithm
-.%O RFC 1321
-.Re
-.Rs
-.%A RSA Laboratories
-.%T Frequently Asked Questions About today's Cryptography
-.%O \&<http://www.rsa.com/rsalabs/faq/>
-.Re
-.Rs
-.%A H. Dobbertin
-.%T Alf Swindles Ann
-.%J CryptoBytes
-.%N 1(3):5
-.%D 1995
-.Re
-.Rs
-.%A MJ. B. Robshaw
-.%T On Recent Results for MD4 and MD5
-.%J RSA Laboratories Bulletin
-.%N 4
-.%D November 12, 1996
-.Re
-.Rs
-.%A Hans Dobbertin
-.%T Cryptanalysis of MD5 Compress
-.Re
-.Sh HISTORY
-These functions appeared in
-.Ox 2.0 .
-.Sh AUTHORS
-The original MDX routines were developed by
-.Tn RSA
-Data Security, Inc., and published in the above references.
-This code is derived from a public domain implementation written by Colin Plumb.
-.Pp
-The
-.Fn MDXEnd ,
-.Fn MDXFile ,
-.Fn MDXFileChunk ,
-and
-.Fn MDXData
-helper functions are derived from code written by Poul-Henning Kamp.
-.Sh BUGS
-Collisions have been found for the full versions of both MD4 and MD5
-as well as strong attacks against the SHA-0 and SHA-1 family.
-The use of
-.Xr sha2 3 ,
-or
-.Xr rmd160 3
-is recommended instead.
+++ /dev/null
-/** $MirOS: src/lib/libc/hash/helper.c,v 1.5 2007/05/07 15:21:18 tg Exp $ */
-/* $OpenBSD: helper.c,v 1.8 2005/08/08 08:05:35 espie Exp $ */
-
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <bsd/md5.h>
-
-/* ARGSUSED */
-char *
-MD5End(MD5_CTX *ctx, char *buf)
-{
- int i;
- u_int8_t digest[MD5_DIGEST_LENGTH];
-#ifdef MD5_DIGEST_UPPERCASE
- static const char hex[] = "0123456789ABCDEF";
-#else
- static const char hex[] = "0123456789abcdef";
-#endif
-
- if (buf == NULL && (buf = malloc(MD5_DIGEST_STRING_LENGTH)) == NULL)
- return (NULL);
-
- MD5Final(digest, ctx);
- for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
- buf[i + i] = hex[digest[i] >> 4];
- buf[i + i + 1] = hex[digest[i] & 0x0f];
- }
- buf[i + i] = '\0';
- memset(digest, 0, sizeof(digest));
- return (buf);
-}
-
-char *
-MD5FileChunk(const char *filename, char *buf, off_t off, off_t len)
-{
- struct stat sb;
- u_char buffer[BUFSIZ];
- MD5_CTX ctx;
- int fd, save_errno;
- ssize_t nr;
-
- MD5Init(&ctx);
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return (NULL);
- if (len == 0) {
- if (fstat(fd, &sb) == -1) {
- close(fd);
- return (NULL);
- }
- len = sb.st_size;
- }
- if ((len < 0) || (off > 0 && lseek(fd, off, SEEK_SET) < 0))
- return (NULL);
-
- while ((nr = read(fd, buffer,
- (size_t)(len ? MIN(BUFSIZ, len) : BUFSIZ))) > 0) {
- MD5Update(&ctx, buffer, (size_t)nr);
- if (len > 0 && (len -= nr) == 0)
- break;
- }
-
- save_errno = errno;
- close(fd);
- errno = save_errno;
- return (nr < 0 ? NULL : MD5End(&ctx, buf));
-}
-
-char *
-MD5File(const char *filename, char *buf)
-{
- return (MD5FileChunk(filename, buf, (off_t)0, (off_t)0));
-}
-
-char *
-MD5Data(const u_char *data, size_t len, char *buf)
-{
- MD5_CTX ctx;
-
- MD5Init(&ctx);
- MD5Update(&ctx, data, len);
- return (MD5End(&ctx, buf));
-}
+++ /dev/null
-#ifndef __ARM_A_OUT_H__
-#define __ARM_A_OUT_H__
-
-#include <linux/personality.h>
-#include <linux/types.h>
-
-struct exec
-{
- __u32 a_info; /* Use macros N_MAGIC, etc for access */
- __u32 a_text; /* length of text, in bytes */
- __u32 a_data; /* length of data, in bytes */
- __u32 a_bss; /* length of uninitialized data area for file, in bytes */
- __u32 a_syms; /* length of symbol table data in file, in bytes */
- __u32 a_entry; /* start address */
- __u32 a_trsize; /* length of relocation info for text, in bytes */
- __u32 a_drsize; /* length of relocation info for data, in bytes */
-};
-
-/*
- * This is always the same
- */
-#define N_TXTADDR(a) (0x00008000)
-
-#define N_TRSIZE(a) ((a).a_trsize)
-#define N_DRSIZE(a) ((a).a_drsize)
-#define N_SYMSIZE(a) ((a).a_syms)
-
-#define M_ARM 103
-
-#ifndef LIBRARY_START_TEXT
-#define LIBRARY_START_TEXT (0x00c00000)
-#endif
-
-#endif /* __A_OUT_GNU_H__ */
+++ /dev/null
-#ifndef _ASM_POWERPC_LINKAGE_H
-#define _ASM_POWERPC_LINKAGE_H
-
-/* Nothing to see here... */
-
-#endif /* _ASM_POWERPC_LINKAGE_H */
+++ /dev/null
-#ifndef __A_OUT_GNU_H__
-#define __A_OUT_GNU_H__
-
-#define __GNU_EXEC_MACROS__
-
-#ifndef __STRUCT_EXEC_OVERRIDE__
-
-#include <asm/a.out.h>
-
-#endif /* __STRUCT_EXEC_OVERRIDE__ */
-
-#ifndef __ASSEMBLY__
-
-/* these go in the N_MACHTYPE field */
-enum machine_type {
-#if defined (M_OLDSUN2)
- M__OLDSUN2 = M_OLDSUN2,
-#else
- M_OLDSUN2 = 0,
-#endif
-#if defined (M_68010)
- M__68010 = M_68010,
-#else
- M_68010 = 1,
-#endif
-#if defined (M_68020)
- M__68020 = M_68020,
-#else
- M_68020 = 2,
-#endif
-#if defined (M_SPARC)
- M__SPARC = M_SPARC,
-#else
- M_SPARC = 3,
-#endif
- /* skip a bunch so we don't run into any of sun's numbers */
- M_386 = 100,
- M_MIPS1 = 151, /* MIPS R3000/R3000 binary */
- M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
-};
-
-#if !defined (N_MAGIC)
-#define N_MAGIC(exec) ((exec).a_info & 0xffff)
-#endif
-#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
-#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
-#define N_SET_INFO(exec, magic, type, flags) \
- ((exec).a_info = ((magic) & 0xffff) \
- | (((int)(type) & 0xff) << 16) \
- | (((flags) & 0xff) << 24))
-#define N_SET_MAGIC(exec, magic) \
- ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
-
-#define N_SET_MACHTYPE(exec, machtype) \
- ((exec).a_info = \
- ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
-
-#define N_SET_FLAGS(exec, flags) \
- ((exec).a_info = \
- ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
-
-/* Code indicating object file or impure executable. */
-#define OMAGIC 0407
-/* Code indicating pure executable. */
-#define NMAGIC 0410
-/* Code indicating demand-paged executable. */
-#define ZMAGIC 0413
-/* This indicates a demand-paged executable with the header in the text.
- The first page is unmapped to help trap NULL pointer references */
-#define QMAGIC 0314
-
-/* Code indicating core file. */
-#define CMAGIC 0421
-
-#if !defined (N_BADMAG)
-#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \
- && N_MAGIC(x) != NMAGIC \
- && N_MAGIC(x) != ZMAGIC \
- && N_MAGIC(x) != QMAGIC)
-#endif
-
-#define _N_HDROFF(x) (1024 - sizeof (struct exec))
-
-#if !defined (N_TXTOFF)
-#define N_TXTOFF(x) \
- (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
- (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
-#endif
-
-#if !defined (N_DATOFF)
-#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
-#endif
-
-#if !defined (N_TRELOFF)
-#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
-#endif
-
-#if !defined (N_DRELOFF)
-#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
-#endif
-
-#if !defined (N_SYMOFF)
-#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
-#endif
-
-#if !defined (N_STROFF)
-#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
-#endif
-
-/* Address of text segment in memory after it is loaded. */
-#if !defined (N_TXTADDR)
-#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? PAGE_SIZE : 0)
-#endif
-
-/* Address of data segment in memory after it is loaded.
- Note that it is up to you to define SEGMENT_SIZE
- on machines not listed here. */
-#if defined(vax) || defined(hp300) || defined(pyr)
-#define SEGMENT_SIZE page_size
-#endif
-#ifdef sony
-#define SEGMENT_SIZE 0x2000
-#endif /* Sony. */
-#ifdef is68k
-#define SEGMENT_SIZE 0x20000
-#endif
-#if defined(m68k) && defined(PORTAR)
-#define PAGE_SIZE 0x400
-#define SEGMENT_SIZE PAGE_SIZE
-#endif
-
-#ifdef linux
-#include <unistd.h>
-#if defined(__i386__) || defined(__mc68000__)
-#define SEGMENT_SIZE 1024
-#else
-#ifndef SEGMENT_SIZE
-#define SEGMENT_SIZE getpagesize()
-#endif
-#endif
-#endif
-
-#define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)
-
-#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
-
-#ifndef N_DATADDR
-#define N_DATADDR(x) \
- (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
- : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
-#endif
-
-/* Address of bss segment in memory after it is loaded. */
-#if !defined (N_BSSADDR)
-#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
-#endif
-\f
-#if !defined (N_NLIST_DECLARED)
-struct nlist {
- union {
- char *n_name;
- struct nlist *n_next;
- long n_strx;
- } n_un;
- unsigned char n_type;
- char n_other;
- short n_desc;
- unsigned long n_value;
-};
-#endif /* no N_NLIST_DECLARED. */
-
-#if !defined (N_UNDF)
-#define N_UNDF 0
-#endif
-#if !defined (N_ABS)
-#define N_ABS 2
-#endif
-#if !defined (N_TEXT)
-#define N_TEXT 4
-#endif
-#if !defined (N_DATA)
-#define N_DATA 6
-#endif
-#if !defined (N_BSS)
-#define N_BSS 8
-#endif
-#if !defined (N_FN)
-#define N_FN 15
-#endif
-
-#if !defined (N_EXT)
-#define N_EXT 1
-#endif
-#if !defined (N_TYPE)
-#define N_TYPE 036
-#endif
-#if !defined (N_STAB)
-#define N_STAB 0340
-#endif
-
-/* The following type indicates the definition of a symbol as being
- an indirect reference to another symbol. The other symbol
- appears as an undefined reference, immediately following this symbol.
-
- Indirection is asymmetrical. The other symbol's value will be used
- to satisfy requests for the indirect symbol, but not vice versa.
- If the other symbol does not have a definition, libraries will
- be searched to find a definition. */
-#define N_INDR 0xa
-
-/* The following symbols refer to set elements.
- All the N_SET[ATDB] symbols with the same name form one set.
- Space is allocated for the set in the text section, and each set
- element's value is stored into one word of the space.
- The first word of the space is the length of the set (number of elements).
-
- The address of the set is made into an N_SETV symbol
- whose name is the same as the name of the set.
- This symbol acts like a N_DATA global symbol
- in that it can satisfy undefined external references. */
-
-/* These appear as input to LD, in a .o file. */
-#define N_SETA 0x14 /* Absolute set element symbol */
-#define N_SETT 0x16 /* Text set element symbol */
-#define N_SETD 0x18 /* Data set element symbol */
-#define N_SETB 0x1A /* Bss set element symbol */
-
-/* This is output from LD. */
-#define N_SETV 0x1C /* Pointer to set vector in data area. */
-\f
-#if !defined (N_RELOCATION_INFO_DECLARED)
-/* This structure describes a single relocation to be performed.
- The text-relocation section of the file is a vector of these structures,
- all of which apply to the text section.
- Likewise, the data-relocation section applies to the data section. */
-
-struct relocation_info
-{
- /* Address (within segment) to be relocated. */
- int r_address;
- /* The meaning of r_symbolnum depends on r_extern. */
- unsigned int r_symbolnum:24;
- /* Nonzero means value is a pc-relative offset
- and it should be relocated for changes in its own address
- as well as for changes in the symbol or section specified. */
- unsigned int r_pcrel:1;
- /* Length (as exponent of 2) of the field to be relocated.
- Thus, a value of 2 indicates 1<<2 bytes. */
- unsigned int r_length:2;
- /* 1 => relocate with value of symbol.
- r_symbolnum is the index of the symbol
- in file's the symbol table.
- 0 => relocate with the address of a segment.
- r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
- (the N_EXT bit may be set also, but signifies nothing). */
- unsigned int r_extern:1;
- /* Four bits that aren't used, but when writing an object file
- it is desirable to clear them. */
-#ifdef NS32K
- unsigned r_bsr:1;
- unsigned r_disp:1;
- unsigned r_pad:2;
-#else
- unsigned int r_pad:4;
-#endif
-};
-#endif /* no N_RELOCATION_INFO_DECLARED. */
-
-#endif /*__ASSEMBLY__ */
-#endif /* __A_OUT_GNU_H__ */
+++ /dev/null
-#ifndef __LINUX_KVM_H
-#define __LINUX_KVM_H
-
-/*
- * Userspace interface for /dev/kvm - kernel based virtual machine
- *
- * Note: you must update KVM_API_VERSION if you change this interface.
- */
-
-#include <linux/types.h>
-
-#include <linux/ioctl.h>
-#include <asm/kvm.h>
-
-#define KVM_API_VERSION 12
-
-/* *** Deprecated interfaces *** */
-
-#define KVM_TRC_SHIFT 16
-
-#define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT)
-#define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1))
-
-#define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01)
-#define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02)
-#define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01)
-
-#define KVM_TRC_HEAD_SIZE 12
-#define KVM_TRC_CYCLE_SIZE 8
-#define KVM_TRC_EXTRA_MAX 7
-
-#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
-#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
-#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
-#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
-#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
-#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
-#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
-#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
-#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
-#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
-#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
-#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
-#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
-#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
-#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
-#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
-#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
-#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
-#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
-#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
-#define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16)
-#define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17)
-#define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18)
-#define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19)
-
-struct kvm_user_trace_setup {
- __u32 buf_size;
- __u32 buf_nr;
-};
-
-#define __KVM_DEPRECATED_MAIN_W_0x06 \
- _IOW(KVMIO, 0x06, struct kvm_user_trace_setup)
-#define __KVM_DEPRECATED_MAIN_0x07 _IO(KVMIO, 0x07)
-#define __KVM_DEPRECATED_MAIN_0x08 _IO(KVMIO, 0x08)
-
-#define __KVM_DEPRECATED_VM_R_0x70 _IOR(KVMIO, 0x70, struct kvm_assigned_irq)
-
-struct kvm_breakpoint {
- __u32 enabled;
- __u32 padding;
- __u64 address;
-};
-
-struct kvm_debug_guest {
- __u32 enabled;
- __u32 pad;
- struct kvm_breakpoint breakpoints[4];
- __u32 singlestep;
-};
-
-#define __KVM_DEPRECATED_VCPU_W_0x87 _IOW(KVMIO, 0x87, struct kvm_debug_guest)
-
-/* *** End of deprecated interfaces *** */
-
-
-/* for KVM_CREATE_MEMORY_REGION */
-struct kvm_memory_region {
- __u32 slot;
- __u32 flags;
- __u64 guest_phys_addr;
- __u64 memory_size; /* bytes */
-};
-
-/* for KVM_SET_USER_MEMORY_REGION */
-struct kvm_userspace_memory_region {
- __u32 slot;
- __u32 flags;
- __u64 guest_phys_addr;
- __u64 memory_size; /* bytes */
- __u64 userspace_addr; /* start of the userspace allocated memory */
-};
-
-/*
- * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace,
- * other bits are reserved for kvm internal use which are defined in
- * include/linux/kvm_host.h.
- */
-#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
-#define KVM_MEM_READONLY (1UL << 1)
-
-/* for KVM_IRQ_LINE */
-struct kvm_irq_level {
- /*
- * ACPI gsi notion of irq.
- * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47..
- * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23..
- * For ARM: See Documentation/virtual/kvm/api.txt
- */
- union {
- __u32 irq;
- __s32 status;
- };
- __u32 level;
-};
-
-
-struct kvm_irqchip {
- __u32 chip_id;
- __u32 pad;
- union {
- char dummy[512]; /* reserving space */
-#ifdef __KVM_HAVE_PIT
- struct kvm_pic_state pic;
-#endif
-#ifdef __KVM_HAVE_IOAPIC
- struct kvm_ioapic_state ioapic;
-#endif
- } chip;
-};
-
-/* for KVM_CREATE_PIT2 */
-struct kvm_pit_config {
- __u32 flags;
- __u32 pad[15];
-};
-
-#define KVM_PIT_SPEAKER_DUMMY 1
-
-#define KVM_EXIT_UNKNOWN 0
-#define KVM_EXIT_EXCEPTION 1
-#define KVM_EXIT_IO 2
-#define KVM_EXIT_HYPERCALL 3
-#define KVM_EXIT_DEBUG 4
-#define KVM_EXIT_HLT 5
-#define KVM_EXIT_MMIO 6
-#define KVM_EXIT_IRQ_WINDOW_OPEN 7
-#define KVM_EXIT_SHUTDOWN 8
-#define KVM_EXIT_FAIL_ENTRY 9
-#define KVM_EXIT_INTR 10
-#define KVM_EXIT_SET_TPR 11
-#define KVM_EXIT_TPR_ACCESS 12
-#define KVM_EXIT_S390_SIEIC 13
-#define KVM_EXIT_S390_RESET 14
-#define KVM_EXIT_DCR 15
-#define KVM_EXIT_NMI 16
-#define KVM_EXIT_INTERNAL_ERROR 17
-#define KVM_EXIT_OSI 18
-#define KVM_EXIT_PAPR_HCALL 19
-#define KVM_EXIT_S390_UCONTROL 20
-#define KVM_EXIT_WATCHDOG 21
-#define KVM_EXIT_S390_TSCH 22
-#define KVM_EXIT_EPR 23
-
-/* For KVM_EXIT_INTERNAL_ERROR */
-/* Emulate instruction failed. */
-#define KVM_INTERNAL_ERROR_EMULATION 1
-/* Encounter unexpected simultaneous exceptions. */
-#define KVM_INTERNAL_ERROR_SIMUL_EX 2
-/* Encounter unexpected vm-exit due to delivery event. */
-#define KVM_INTERNAL_ERROR_DELIVERY_EV 3
-
-/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
-struct kvm_run {
- /* in */
- __u8 request_interrupt_window;
- __u8 padding1[7];
-
- /* out */
- __u32 exit_reason;
- __u8 ready_for_interrupt_injection;
- __u8 if_flag;
- __u8 padding2[2];
-
- /* in (pre_kvm_run), out (post_kvm_run) */
- __u64 cr8;
- __u64 apic_base;
-
-#ifdef __KVM_S390
- /* the processor status word for s390 */
- __u64 psw_mask; /* psw upper half */
- __u64 psw_addr; /* psw lower half */
-#endif
- union {
- /* KVM_EXIT_UNKNOWN */
- struct {
- __u64 hardware_exit_reason;
- } hw;
- /* KVM_EXIT_FAIL_ENTRY */
- struct {
- __u64 hardware_entry_failure_reason;
- } fail_entry;
- /* KVM_EXIT_EXCEPTION */
- struct {
- __u32 exception;
- __u32 error_code;
- } ex;
- /* KVM_EXIT_IO */
- struct {
-#define KVM_EXIT_IO_IN 0
-#define KVM_EXIT_IO_OUT 1
- __u8 direction;
- __u8 size; /* bytes */
- __u16 port;
- __u32 count;
- __u64 data_offset; /* relative to kvm_run start */
- } io;
- struct {
- struct kvm_debug_exit_arch arch;
- } debug;
- /* KVM_EXIT_MMIO */
- struct {
- __u64 phys_addr;
- __u8 data[8];
- __u32 len;
- __u8 is_write;
- } mmio;
- /* KVM_EXIT_HYPERCALL */
- struct {
- __u64 nr;
- __u64 args[6];
- __u64 ret;
- __u32 longmode;
- __u32 pad;
- } hypercall;
- /* KVM_EXIT_TPR_ACCESS */
- struct {
- __u64 rip;
- __u32 is_write;
- __u32 pad;
- } tpr_access;
- /* KVM_EXIT_S390_SIEIC */
- struct {
- __u8 icptcode;
- __u16 ipa;
- __u32 ipb;
- } s390_sieic;
- /* KVM_EXIT_S390_RESET */
-#define KVM_S390_RESET_POR 1
-#define KVM_S390_RESET_CLEAR 2
-#define KVM_S390_RESET_SUBSYSTEM 4
-#define KVM_S390_RESET_CPU_INIT 8
-#define KVM_S390_RESET_IPL 16
- __u64 s390_reset_flags;
- /* KVM_EXIT_S390_UCONTROL */
- struct {
- __u64 trans_exc_code;
- __u32 pgm_code;
- } s390_ucontrol;
- /* KVM_EXIT_DCR */
- struct {
- __u32 dcrn;
- __u32 data;
- __u8 is_write;
- } dcr;
- struct {
- __u32 suberror;
- /* Available with KVM_CAP_INTERNAL_ERROR_DATA: */
- __u32 ndata;
- __u64 data[16];
- } internal;
- /* KVM_EXIT_OSI */
- struct {
- __u64 gprs[32];
- } osi;
- struct {
- __u64 nr;
- __u64 ret;
- __u64 args[9];
- } papr_hcall;
- /* KVM_EXIT_S390_TSCH */
- struct {
- __u16 subchannel_id;
- __u16 subchannel_nr;
- __u32 io_int_parm;
- __u32 io_int_word;
- __u32 ipb;
- __u8 dequeued;
- } s390_tsch;
- /* KVM_EXIT_EPR */
- struct {
- __u32 epr;
- } epr;
- /* Fix the size of the union. */
- char padding[256];
- };
-
- /*
- * shared registers between kvm and userspace.
- * kvm_valid_regs specifies the register classes set by the host
- * kvm_dirty_regs specified the register classes dirtied by userspace
- * struct kvm_sync_regs is architecture specific, as well as the
- * bits for kvm_valid_regs and kvm_dirty_regs
- */
- __u64 kvm_valid_regs;
- __u64 kvm_dirty_regs;
- union {
- struct kvm_sync_regs regs;
- char padding[1024];
- } s;
-};
-
-/* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
-
-struct kvm_coalesced_mmio_zone {
- __u64 addr;
- __u32 size;
- __u32 pad;
-};
-
-struct kvm_coalesced_mmio {
- __u64 phys_addr;
- __u32 len;
- __u32 pad;
- __u8 data[8];
-};
-
-struct kvm_coalesced_mmio_ring {
- __u32 first, last;
- struct kvm_coalesced_mmio coalesced_mmio[0];
-};
-
-#define KVM_COALESCED_MMIO_MAX \
- ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \
- sizeof(struct kvm_coalesced_mmio))
-
-/* for KVM_TRANSLATE */
-struct kvm_translation {
- /* in */
- __u64 linear_address;
-
- /* out */
- __u64 physical_address;
- __u8 valid;
- __u8 writeable;
- __u8 usermode;
- __u8 pad[5];
-};
-
-/* for KVM_INTERRUPT */
-struct kvm_interrupt {
- /* in */
- __u32 irq;
-};
-
-/* for KVM_GET_DIRTY_LOG */
-struct kvm_dirty_log {
- __u32 slot;
- __u32 padding1;
- union {
- void *dirty_bitmap; /* one bit per page */
- __u64 padding2;
- };
-};
-
-/* for KVM_SET_SIGNAL_MASK */
-struct kvm_signal_mask {
- __u32 len;
- __u8 sigset[0];
-};
-
-/* for KVM_TPR_ACCESS_REPORTING */
-struct kvm_tpr_access_ctl {
- __u32 enabled;
- __u32 flags;
- __u32 reserved[8];
-};
-
-/* for KVM_SET_VAPIC_ADDR */
-struct kvm_vapic_addr {
- __u64 vapic_addr;
-};
-
-/* for KVM_SET_MPSTATE */
-
-#define KVM_MP_STATE_RUNNABLE 0
-#define KVM_MP_STATE_UNINITIALIZED 1
-#define KVM_MP_STATE_INIT_RECEIVED 2
-#define KVM_MP_STATE_HALTED 3
-#define KVM_MP_STATE_SIPI_RECEIVED 4
-
-struct kvm_mp_state {
- __u32 mp_state;
-};
-
-struct kvm_s390_psw {
- __u64 mask;
- __u64 addr;
-};
-
-/* valid values for type in kvm_s390_interrupt */
-#define KVM_S390_SIGP_STOP 0xfffe0000u
-#define KVM_S390_PROGRAM_INT 0xfffe0001u
-#define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u
-#define KVM_S390_RESTART 0xfffe0003u
-#define KVM_S390_MCHK 0xfffe1000u
-#define KVM_S390_INT_VIRTIO 0xffff2603u
-#define KVM_S390_INT_SERVICE 0xffff2401u
-#define KVM_S390_INT_EMERGENCY 0xffff1201u
-#define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u
-/* Anything below 0xfffe0000u is taken by INT_IO */
-#define KVM_S390_INT_IO(ai,cssid,ssid,schid) \
- (((schid)) | \
- ((ssid) << 16) | \
- ((cssid) << 18) | \
- ((ai) << 26))
-#define KVM_S390_INT_IO_MIN 0x00000000u
-#define KVM_S390_INT_IO_MAX 0xfffdffffu
-
-
-struct kvm_s390_interrupt {
- __u32 type;
- __u32 parm;
- __u64 parm64;
-};
-
-/* for KVM_SET_GUEST_DEBUG */
-
-#define KVM_GUESTDBG_ENABLE 0x00000001
-#define KVM_GUESTDBG_SINGLESTEP 0x00000002
-
-struct kvm_guest_debug {
- __u32 control;
- __u32 pad;
- struct kvm_guest_debug_arch arch;
-};
-
-enum {
- kvm_ioeventfd_flag_nr_datamatch,
- kvm_ioeventfd_flag_nr_pio,
- kvm_ioeventfd_flag_nr_deassign,
- kvm_ioeventfd_flag_nr_max,
-};
-
-#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
-#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
-#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
-
-#define KVM_IOEVENTFD_VALID_FLAG_MASK ((1 << kvm_ioeventfd_flag_nr_max) - 1)
-
-struct kvm_ioeventfd {
- __u64 datamatch;
- __u64 addr; /* legal pio/mmio address */
- __u32 len; /* 1, 2, 4, or 8 bytes */
- __s32 fd;
- __u32 flags;
- __u8 pad[36];
-};
-
-/* for KVM_ENABLE_CAP */
-struct kvm_enable_cap {
- /* in */
- __u32 cap;
- __u32 flags;
- __u64 args[4];
- __u8 pad[64];
-};
-
-/* for KVM_PPC_GET_PVINFO */
-struct kvm_ppc_pvinfo {
- /* out */
- __u32 flags;
- __u32 hcall[4];
- __u8 pad[108];
-};
-
-/* for KVM_PPC_GET_SMMU_INFO */
-#define KVM_PPC_PAGE_SIZES_MAX_SZ 8
-
-struct kvm_ppc_one_page_size {
- __u32 page_shift; /* Page shift (or 0) */
- __u32 pte_enc; /* Encoding in the HPTE (>>12) */
-};
-
-struct kvm_ppc_one_seg_page_size {
- __u32 page_shift; /* Base page shift of segment (or 0) */
- __u32 slb_enc; /* SLB encoding for BookS */
- struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
-};
-
-#define KVM_PPC_PAGE_SIZES_REAL 0x00000001
-#define KVM_PPC_1T_SEGMENTS 0x00000002
-
-struct kvm_ppc_smmu_info {
- __u64 flags;
- __u32 slb_size;
- __u32 pad;
- struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
-};
-
-#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0)
-
-#define KVMIO 0xAE
-
-/* machine type bits, to be used as argument to KVM_CREATE_VM */
-#define KVM_VM_S390_UCONTROL 1
-
-#define KVM_S390_SIE_PAGE_OFFSET 1
-
-/*
- * ioctls for /dev/kvm fds:
- */
-#define KVM_GET_API_VERSION _IO(KVMIO, 0x00)
-#define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */
-#define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list)
-
-#define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06)
-/*
- * Check if a kvm extension is available. Argument is extension number,
- * return is 1 (yes) or 0 (no, sorry).
- */
-#define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
-/*
- * Get size for mmap(vcpu_fd)
- */
-#define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */
-#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2)
-#define KVM_TRACE_ENABLE __KVM_DEPRECATED_MAIN_W_0x06
-#define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07
-#define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08
-
-/*
- * Extension capability list.
- */
-#define KVM_CAP_IRQCHIP 0
-#define KVM_CAP_HLT 1
-#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
-#define KVM_CAP_USER_MEMORY 3
-#define KVM_CAP_SET_TSS_ADDR 4
-#define KVM_CAP_VAPIC 6
-#define KVM_CAP_EXT_CPUID 7
-#define KVM_CAP_CLOCKSOURCE 8
-#define KVM_CAP_NR_VCPUS 9 /* returns recommended max vcpus per vm */
-#define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */
-#define KVM_CAP_PIT 11
-#define KVM_CAP_NOP_IO_DELAY 12
-#define KVM_CAP_PV_MMU 13
-#define KVM_CAP_MP_STATE 14
-#define KVM_CAP_COALESCED_MMIO 15
-#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */
-#ifdef __KVM_HAVE_DEVICE_ASSIGNMENT
-#define KVM_CAP_DEVICE_ASSIGNMENT 17
-#endif
-#define KVM_CAP_IOMMU 18
-#ifdef __KVM_HAVE_MSI
-#define KVM_CAP_DEVICE_MSI 20
-#endif
-/* Bug in KVM_SET_USER_MEMORY_REGION fixed: */
-#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
-#ifdef __KVM_HAVE_USER_NMI
-#define KVM_CAP_USER_NMI 22
-#endif
-#ifdef __KVM_HAVE_GUEST_DEBUG
-#define KVM_CAP_SET_GUEST_DEBUG 23
-#endif
-#ifdef __KVM_HAVE_PIT
-#define KVM_CAP_REINJECT_CONTROL 24
-#endif
-#ifdef __KVM_HAVE_IOAPIC
-#define KVM_CAP_IRQ_ROUTING 25
-#endif
-#define KVM_CAP_IRQ_INJECT_STATUS 26
-#ifdef __KVM_HAVE_DEVICE_ASSIGNMENT
-#define KVM_CAP_DEVICE_DEASSIGNMENT 27
-#endif
-#ifdef __KVM_HAVE_MSIX
-#define KVM_CAP_DEVICE_MSIX 28
-#endif
-#define KVM_CAP_ASSIGN_DEV_IRQ 29
-/* Another bug in KVM_SET_USER_MEMORY_REGION fixed: */
-#define KVM_CAP_JOIN_MEMORY_REGIONS_WORKS 30
-#ifdef __KVM_HAVE_MCE
-#define KVM_CAP_MCE 31
-#endif
-#define KVM_CAP_IRQFD 32
-#ifdef __KVM_HAVE_PIT
-#define KVM_CAP_PIT2 33
-#endif
-#define KVM_CAP_SET_BOOT_CPU_ID 34
-#ifdef __KVM_HAVE_PIT_STATE2
-#define KVM_CAP_PIT_STATE2 35
-#endif
-#define KVM_CAP_IOEVENTFD 36
-#define KVM_CAP_SET_IDENTITY_MAP_ADDR 37
-#ifdef __KVM_HAVE_XEN_HVM
-#define KVM_CAP_XEN_HVM 38
-#endif
-#define KVM_CAP_ADJUST_CLOCK 39
-#define KVM_CAP_INTERNAL_ERROR_DATA 40
-#ifdef __KVM_HAVE_VCPU_EVENTS
-#define KVM_CAP_VCPU_EVENTS 41
-#endif
-#define KVM_CAP_S390_PSW 42
-#define KVM_CAP_PPC_SEGSTATE 43
-#define KVM_CAP_HYPERV 44
-#define KVM_CAP_HYPERV_VAPIC 45
-#define KVM_CAP_HYPERV_SPIN 46
-#define KVM_CAP_PCI_SEGMENT 47
-#define KVM_CAP_PPC_PAIRED_SINGLES 48
-#define KVM_CAP_INTR_SHADOW 49
-#ifdef __KVM_HAVE_DEBUGREGS
-#define KVM_CAP_DEBUGREGS 50
-#endif
-#define KVM_CAP_X86_ROBUST_SINGLESTEP 51
-#define KVM_CAP_PPC_OSI 52
-#define KVM_CAP_PPC_UNSET_IRQ 53
-#define KVM_CAP_ENABLE_CAP 54
-#ifdef __KVM_HAVE_XSAVE
-#define KVM_CAP_XSAVE 55
-#endif
-#ifdef __KVM_HAVE_XCRS
-#define KVM_CAP_XCRS 56
-#endif
-#define KVM_CAP_PPC_GET_PVINFO 57
-#define KVM_CAP_PPC_IRQ_LEVEL 58
-#define KVM_CAP_ASYNC_PF 59
-#define KVM_CAP_TSC_CONTROL 60
-#define KVM_CAP_GET_TSC_KHZ 61
-#define KVM_CAP_PPC_BOOKE_SREGS 62
-#define KVM_CAP_SPAPR_TCE 63
-#define KVM_CAP_PPC_SMT 64
-#define KVM_CAP_PPC_RMA 65
-#define KVM_CAP_MAX_VCPUS 66 /* returns max vcpus per vm */
-#define KVM_CAP_PPC_HIOR 67
-#define KVM_CAP_PPC_PAPR 68
-#define KVM_CAP_SW_TLB 69
-#define KVM_CAP_ONE_REG 70
-#define KVM_CAP_S390_GMAP 71
-#define KVM_CAP_TSC_DEADLINE_TIMER 72
-#define KVM_CAP_S390_UCONTROL 73
-#define KVM_CAP_SYNC_REGS 74
-#define KVM_CAP_PCI_2_3 75
-#define KVM_CAP_KVMCLOCK_CTRL 76
-#define KVM_CAP_SIGNAL_MSI 77
-#define KVM_CAP_PPC_GET_SMMU_INFO 78
-#define KVM_CAP_S390_COW 79
-#define KVM_CAP_PPC_ALLOC_HTAB 80
-#ifdef __KVM_HAVE_READONLY_MEM
-#define KVM_CAP_READONLY_MEM 81
-#endif
-#define KVM_CAP_IRQFD_RESAMPLE 82
-#define KVM_CAP_PPC_BOOKE_WATCHDOG 83
-#define KVM_CAP_PPC_HTAB_FD 84
-#define KVM_CAP_S390_CSS_SUPPORT 85
-#define KVM_CAP_PPC_EPR 86
-#define KVM_CAP_ARM_PSCI 87
-#define KVM_CAP_ARM_SET_DEVICE_ADDR 88
-
-#ifdef KVM_CAP_IRQ_ROUTING
-
-struct kvm_irq_routing_irqchip {
- __u32 irqchip;
- __u32 pin;
-};
-
-struct kvm_irq_routing_msi {
- __u32 address_lo;
- __u32 address_hi;
- __u32 data;
- __u32 pad;
-};
-
-/* gsi routing entry types */
-#define KVM_IRQ_ROUTING_IRQCHIP 1
-#define KVM_IRQ_ROUTING_MSI 2
-
-struct kvm_irq_routing_entry {
- __u32 gsi;
- __u32 type;
- __u32 flags;
- __u32 pad;
- union {
- struct kvm_irq_routing_irqchip irqchip;
- struct kvm_irq_routing_msi msi;
- __u32 pad[8];
- } u;
-};
-
-struct kvm_irq_routing {
- __u32 nr;
- __u32 flags;
- struct kvm_irq_routing_entry entries[0];
-};
-
-#endif
-
-#ifdef KVM_CAP_MCE
-/* x86 MCE */
-struct kvm_x86_mce {
- __u64 status;
- __u64 addr;
- __u64 misc;
- __u64 mcg_status;
- __u8 bank;
- __u8 pad1[7];
- __u64 pad2[3];
-};
-#endif
-
-#ifdef KVM_CAP_XEN_HVM
-struct kvm_xen_hvm_config {
- __u32 flags;
- __u32 msr;
- __u64 blob_addr_32;
- __u64 blob_addr_64;
- __u8 blob_size_32;
- __u8 blob_size_64;
- __u8 pad2[30];
-};
-#endif
-
-#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
-/*
- * Available with KVM_CAP_IRQFD_RESAMPLE
- *
- * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies
- * the irqfd to operate in resampling mode for level triggered interrupt
- * emlation. See Documentation/virtual/kvm/api.txt.
- */
-#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
-
-struct kvm_irqfd {
- __u32 fd;
- __u32 gsi;
- __u32 flags;
- __u32 resamplefd;
- __u8 pad[16];
-};
-
-struct kvm_clock_data {
- __u64 clock;
- __u32 flags;
- __u32 pad[9];
-};
-
-#define KVM_MMU_FSL_BOOKE_NOHV 0
-#define KVM_MMU_FSL_BOOKE_HV 1
-
-struct kvm_config_tlb {
- __u64 params;
- __u64 array;
- __u32 mmu_type;
- __u32 array_len;
-};
-
-struct kvm_dirty_tlb {
- __u64 bitmap;
- __u32 num_dirty;
-};
-
-/* Available with KVM_CAP_ONE_REG */
-
-#define KVM_REG_ARCH_MASK 0xff00000000000000ULL
-#define KVM_REG_GENERIC 0x0000000000000000ULL
-
-/*
- * Architecture specific registers are to be defined in arch headers and
- * ORed with the arch identifier.
- */
-#define KVM_REG_PPC 0x1000000000000000ULL
-#define KVM_REG_X86 0x2000000000000000ULL
-#define KVM_REG_IA64 0x3000000000000000ULL
-#define KVM_REG_ARM 0x4000000000000000ULL
-#define KVM_REG_S390 0x5000000000000000ULL
-
-#define KVM_REG_SIZE_SHIFT 52
-#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
-#define KVM_REG_SIZE_U8 0x0000000000000000ULL
-#define KVM_REG_SIZE_U16 0x0010000000000000ULL
-#define KVM_REG_SIZE_U32 0x0020000000000000ULL
-#define KVM_REG_SIZE_U64 0x0030000000000000ULL
-#define KVM_REG_SIZE_U128 0x0040000000000000ULL
-#define KVM_REG_SIZE_U256 0x0050000000000000ULL
-#define KVM_REG_SIZE_U512 0x0060000000000000ULL
-#define KVM_REG_SIZE_U1024 0x0070000000000000ULL
-
-struct kvm_reg_list {
- __u64 n; /* number of regs */
- __u64 reg[0];
-};
-
-struct kvm_one_reg {
- __u64 id;
- __u64 addr;
-};
-
-struct kvm_msi {
- __u32 address_lo;
- __u32 address_hi;
- __u32 data;
- __u32 flags;
- __u8 pad[16];
-};
-
-struct kvm_arm_device_addr {
- __u64 id;
- __u64 addr;
-};
-
-/*
- * ioctls for VM fds
- */
-#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
-/*
- * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
- * a vcpu fd.
- */
-#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
-#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
-/* KVM_SET_MEMORY_ALIAS is obsolete: */
-#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
-#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
-#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
-#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
- struct kvm_userspace_memory_region)
-#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
-#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
-
-/* enable ucontrol for s390 */
-struct kvm_s390_ucas_mapping {
- __u64 user_addr;
- __u64 vcpu_addr;
- __u64 length;
-};
-#define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
-#define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
-#define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
-
-/* Device model IOC */
-#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
-#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
-#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
-#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
-#define KVM_CREATE_PIT _IO(KVMIO, 0x64)
-#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
-#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
-#define KVM_IRQ_LINE_STATUS _IOWR(KVMIO, 0x67, struct kvm_irq_level)
-#define KVM_REGISTER_COALESCED_MMIO \
- _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
-#define KVM_UNREGISTER_COALESCED_MMIO \
- _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
-#define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \
- struct kvm_assigned_pci_dev)
-#define KVM_SET_GSI_ROUTING _IOW(KVMIO, 0x6a, struct kvm_irq_routing)
-/* deprecated, replaced by KVM_ASSIGN_DEV_IRQ */
-#define KVM_ASSIGN_IRQ __KVM_DEPRECATED_VM_R_0x70
-#define KVM_ASSIGN_DEV_IRQ _IOW(KVMIO, 0x70, struct kvm_assigned_irq)
-#define KVM_REINJECT_CONTROL _IO(KVMIO, 0x71)
-#define KVM_DEASSIGN_PCI_DEVICE _IOW(KVMIO, 0x72, \
- struct kvm_assigned_pci_dev)
-#define KVM_ASSIGN_SET_MSIX_NR _IOW(KVMIO, 0x73, \
- struct kvm_assigned_msix_nr)
-#define KVM_ASSIGN_SET_MSIX_ENTRY _IOW(KVMIO, 0x74, \
- struct kvm_assigned_msix_entry)
-#define KVM_DEASSIGN_DEV_IRQ _IOW(KVMIO, 0x75, struct kvm_assigned_irq)
-#define KVM_IRQFD _IOW(KVMIO, 0x76, struct kvm_irqfd)
-#define KVM_CREATE_PIT2 _IOW(KVMIO, 0x77, struct kvm_pit_config)
-#define KVM_SET_BOOT_CPU_ID _IO(KVMIO, 0x78)
-#define KVM_IOEVENTFD _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
-#define KVM_XEN_HVM_CONFIG _IOW(KVMIO, 0x7a, struct kvm_xen_hvm_config)
-#define KVM_SET_CLOCK _IOW(KVMIO, 0x7b, struct kvm_clock_data)
-#define KVM_GET_CLOCK _IOR(KVMIO, 0x7c, struct kvm_clock_data)
-/* Available with KVM_CAP_PIT_STATE2 */
-#define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2)
-#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
-/* Available with KVM_CAP_PPC_GET_PVINFO */
-#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
-/* Available with KVM_CAP_TSC_CONTROL */
-#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
-#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
-/* Available with KVM_CAP_PCI_2_3 */
-#define KVM_ASSIGN_SET_INTX_MASK _IOW(KVMIO, 0xa4, \
- struct kvm_assigned_pci_dev)
-/* Available with KVM_CAP_SIGNAL_MSI */
-#define KVM_SIGNAL_MSI _IOW(KVMIO, 0xa5, struct kvm_msi)
-/* Available with KVM_CAP_PPC_GET_SMMU_INFO */
-#define KVM_PPC_GET_SMMU_INFO _IOR(KVMIO, 0xa6, struct kvm_ppc_smmu_info)
-/* Available with KVM_CAP_PPC_ALLOC_HTAB */
-#define KVM_PPC_ALLOCATE_HTAB _IOWR(KVMIO, 0xa7, __u32)
-#define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce)
-/* Available with KVM_CAP_RMA */
-#define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)
-/* Available with KVM_CAP_PPC_HTAB_FD */
-#define KVM_PPC_GET_HTAB_FD _IOW(KVMIO, 0xaa, struct kvm_get_htab_fd)
-/* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */
-#define KVM_ARM_SET_DEVICE_ADDR _IOW(KVMIO, 0xab, struct kvm_arm_device_addr)
-
-/*
- * ioctls for vcpu fds
- */
-#define KVM_RUN _IO(KVMIO, 0x80)
-#define KVM_GET_REGS _IOR(KVMIO, 0x81, struct kvm_regs)
-#define KVM_SET_REGS _IOW(KVMIO, 0x82, struct kvm_regs)
-#define KVM_GET_SREGS _IOR(KVMIO, 0x83, struct kvm_sregs)
-#define KVM_SET_SREGS _IOW(KVMIO, 0x84, struct kvm_sregs)
-#define KVM_TRANSLATE _IOWR(KVMIO, 0x85, struct kvm_translation)
-#define KVM_INTERRUPT _IOW(KVMIO, 0x86, struct kvm_interrupt)
-/* KVM_DEBUG_GUEST is no longer supported, use KVM_SET_GUEST_DEBUG instead */
-#define KVM_DEBUG_GUEST __KVM_DEPRECATED_VCPU_W_0x87
-#define KVM_GET_MSRS _IOWR(KVMIO, 0x88, struct kvm_msrs)
-#define KVM_SET_MSRS _IOW(KVMIO, 0x89, struct kvm_msrs)
-#define KVM_SET_CPUID _IOW(KVMIO, 0x8a, struct kvm_cpuid)
-#define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
-#define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
-#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
-#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)
-#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)
-#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2)
-#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
-/* Available with KVM_CAP_VAPIC */
-#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
-/* Available with KVM_CAP_VAPIC */
-#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
-/* valid for virtual machine (for floating interrupt)_and_ vcpu */
-#define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt)
-/* store status for s390 */
-#define KVM_S390_STORE_STATUS_NOADDR (-1ul)
-#define KVM_S390_STORE_STATUS_PREFIXED (-2ul)
-#define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long)
-/* initial ipl psw for s390 */
-#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)
-/* initial reset for s390 */
-#define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97)
-#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
-#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
-/* Available with KVM_CAP_NMI */
-#define KVM_NMI _IO(KVMIO, 0x9a)
-/* Available with KVM_CAP_SET_GUEST_DEBUG */
-#define KVM_SET_GUEST_DEBUG _IOW(KVMIO, 0x9b, struct kvm_guest_debug)
-/* MCE for x86 */
-#define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64)
-#define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64)
-#define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce)
-/* IA64 stack access */
-#define KVM_IA64_VCPU_GET_STACK _IOR(KVMIO, 0x9a, void *)
-#define KVM_IA64_VCPU_SET_STACK _IOW(KVMIO, 0x9b, void *)
-/* Available with KVM_CAP_VCPU_EVENTS */
-#define KVM_GET_VCPU_EVENTS _IOR(KVMIO, 0x9f, struct kvm_vcpu_events)
-#define KVM_SET_VCPU_EVENTS _IOW(KVMIO, 0xa0, struct kvm_vcpu_events)
-/* Available with KVM_CAP_DEBUGREGS */
-#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
-#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
-#define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
-/* Available with KVM_CAP_XSAVE */
-#define KVM_GET_XSAVE _IOR(KVMIO, 0xa4, struct kvm_xsave)
-#define KVM_SET_XSAVE _IOW(KVMIO, 0xa5, struct kvm_xsave)
-/* Available with KVM_CAP_XCRS */
-#define KVM_GET_XCRS _IOR(KVMIO, 0xa6, struct kvm_xcrs)
-#define KVM_SET_XCRS _IOW(KVMIO, 0xa7, struct kvm_xcrs)
-/* Available with KVM_CAP_SW_TLB */
-#define KVM_DIRTY_TLB _IOW(KVMIO, 0xaa, struct kvm_dirty_tlb)
-/* Available with KVM_CAP_ONE_REG */
-#define KVM_GET_ONE_REG _IOW(KVMIO, 0xab, struct kvm_one_reg)
-#define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg)
-/* VM is being stopped by host */
-#define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad)
-#define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init)
-#define KVM_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
-
-#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
-#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
-#define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
-
-struct kvm_assigned_pci_dev {
- __u32 assigned_dev_id;
- __u32 busnr;
- __u32 devfn;
- __u32 flags;
- __u32 segnr;
- union {
- __u32 reserved[11];
- };
-};
-
-#define KVM_DEV_IRQ_HOST_INTX (1 << 0)
-#define KVM_DEV_IRQ_HOST_MSI (1 << 1)
-#define KVM_DEV_IRQ_HOST_MSIX (1 << 2)
-
-#define KVM_DEV_IRQ_GUEST_INTX (1 << 8)
-#define KVM_DEV_IRQ_GUEST_MSI (1 << 9)
-#define KVM_DEV_IRQ_GUEST_MSIX (1 << 10)
-
-#define KVM_DEV_IRQ_HOST_MASK 0x00ff
-#define KVM_DEV_IRQ_GUEST_MASK 0xff00
-
-struct kvm_assigned_irq {
- __u32 assigned_dev_id;
- __u32 host_irq; /* ignored (legacy field) */
- __u32 guest_irq;
- __u32 flags;
- union {
- __u32 reserved[12];
- };
-};
-
-struct kvm_assigned_msix_nr {
- __u32 assigned_dev_id;
- __u16 entry_nr;
- __u16 padding;
-};
-
-#define KVM_MAX_MSIX_PER_DEV 256
-struct kvm_assigned_msix_entry {
- __u32 assigned_dev_id;
- __u32 gsi;
- __u16 entry; /* The index of entry in the MSI-X table */
- __u16 padding[3];
-};
-
-#endif /* __LINUX_KVM_H */
+++ /dev/null
-TARGET_alpha=y
+++ /dev/null
-TARGET_arm=y
+++ /dev/null
-TARGET_avr32=y
+++ /dev/null
-TARGET_bfin=y
+++ /dev/null
-TARGET_cris=y
+++ /dev/null
-TARGET_e1=y
+++ /dev/null
-TARGET_frv=y
+++ /dev/null
-TARGET_h8300=y
+++ /dev/null
-TARGET_hppa=y
+++ /dev/null
-TARGET_i386=y
+++ /dev/null
-TARGET_i960=y
+++ /dev/null
-TARGET_ia64=y
+++ /dev/null
-TARGET_m68k=y
+++ /dev/null
-TARGET_microblaze=y
+++ /dev/null
-TARGET_mips=y
+++ /dev/null
-TARGET_nios=y
+++ /dev/null
-TARGET_nios2=y
+++ /dev/null
-TARGET_powerpc=y
+++ /dev/null
-TARGET_sh=y
+++ /dev/null
-TARGET_sh64=y
+++ /dev/null
-TARGET_sparc=y
+++ /dev/null
-TARGET_v850=y
+++ /dev/null
-TARGET_vax=y
+++ /dev/null
-TARGET_x86_64=y
+++ /dev/null
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lkc.h"
-
-#define P(name,type,arg) type (*name ## _p) arg
-#include "lkc_proto.h"
-#undef P
-
-void kconfig_load(void)
-{
- void *handle;
- char *error;
-
- handle = dlopen("./libkconfig.so", RTLD_LAZY);
- if (!handle) {
- handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY);
- if (!handle) {
- fprintf(stderr, "%s\n", dlerror());
- exit(1);
- }
- }
-
-#define P(name,type,arg) \
-{ \
- name ## _p = dlsym(handle, #name); \
- if ((error = dlerror())) { \
- fprintf(stderr, "%s\n", error); \
- exit(1); \
- } \
-}
-#include "lkc_proto.h"
-#undef P
-}
+++ /dev/null
-
-#line 3 "scripts/kconfig/lex.zconf.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define yy_create_buffer zconf_create_buffer
-#define yy_delete_buffer zconf_delete_buffer
-#define yy_flex_debug zconf_flex_debug
-#define yy_init_buffer zconf_init_buffer
-#define yy_flush_buffer zconf_flush_buffer
-#define yy_load_buffer_state zconf_load_buffer_state
-#define yy_switch_to_buffer zconf_switch_to_buffer
-#define yyin zconfin
-#define yyleng zconfleng
-#define yylex zconflex
-#define yylineno zconflineno
-#define yyout zconfout
-#define yyrestart zconfrestart
-#define yytext zconftext
-#define yywrap zconfwrap
-#define yyalloc zconfalloc
-#define yyrealloc zconfrealloc
-#define yyfree zconffree
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE zconfrestart(zconfin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int zconfleng;
-
-extern FILE *zconfin, *zconfout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up zconftext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up zconftext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via zconfrestart()), so that the user can continue scanning by
- * just pointing zconfin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when zconftext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int zconfleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow zconfwrap()'s to do buffer switches
- * instead of setting up a fresh zconfin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void zconfrestart (FILE *input_file );
-void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size );
-void zconf_delete_buffer (YY_BUFFER_STATE b );
-void zconf_flush_buffer (YY_BUFFER_STATE b );
-void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer );
-void zconfpop_buffer_state (void );
-
-static void zconfensure_buffer_stack (void );
-static void zconf_load_buffer_state (void );
-static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len );
-
-void *zconfalloc (yy_size_t );
-void *zconfrealloc (void *,yy_size_t );
-void zconffree (void * );
-
-#define yy_new_buffer zconf_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- zconfensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- zconfensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-#define zconfwrap(n) 1
-#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
-
-FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int zconflineno;
-
-int zconflineno = 1;
-
-extern char *zconftext;
-#define yytext_ptr zconftext
-static yyconst flex_int16_t yy_nxt[][17] =
- {
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
- },
-
- {
- 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12
- },
-
- {
- 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12
- },
-
- {
- 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 18, 16, 16, 16
- },
-
- {
- 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 18, 16, 16, 16
-
- },
-
- {
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19
- },
-
- {
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19
- },
-
- {
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 25, 22
- },
-
- {
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 25, 22
- },
-
- {
- 11, 26, 26, 27, 28, 29, 30, 31, 29, 32,
- 33, 34, 35, 35, 36, 37, 38
-
- },
-
- {
- 11, 26, 26, 27, 28, 29, 30, 31, 29, 32,
- 33, 34, 35, 35, 36, 37, 38
- },
-
- {
- -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
- -11, -11, -11, -11, -11, -11, -11
- },
-
- {
- 11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
- -12, -12, -12, -12, -12, -12, -12
- },
-
- {
- 11, -13, 39, 40, -13, -13, 41, -13, -13, -13,
- -13, -13, -13, -13, -13, -13, -13
- },
-
- {
- 11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
- -14, -14, -14, -14, -14, -14, -14
-
- },
-
- {
- 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 42
- },
-
- {
- 11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
- -16, -16, -16, -16, -16, -16, -16
- },
-
- {
- 11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
- -17, -17, -17, -17, -17, -17, -17
- },
-
- {
- 11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
- -18, -18, -18, 44, -18, -18, -18
- },
-
- {
- 11, 45, 45, -19, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45
-
- },
-
- {
- 11, -20, 46, 47, -20, -20, -20, -20, -20, -20,
- -20, -20, -20, -20, -20, -20, -20
- },
-
- {
- 11, 48, -21, -21, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48
- },
-
- {
- 11, 49, 49, 50, 49, -22, 49, 49, -22, 49,
- 49, 49, 49, 49, 49, -22, 49
- },
-
- {
- 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
- -23, -23, -23, -23, -23, -23, -23
- },
-
- {
- 11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- -24, -24, -24, -24, -24, -24, -24
-
- },
-
- {
- 11, 51, 51, 52, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51
- },
-
- {
- 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
- -26, -26, -26, -26, -26, -26, -26
- },
-
- {
- 11, -27, -27, -27, -27, -27, -27, -27, -27, -27,
- -27, -27, -27, -27, -27, -27, -27
- },
-
- {
- 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
- -28, -28, -28, -28, 53, -28, -28
- },
-
- {
- 11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
- -29, -29, -29, -29, -29, -29, -29
-
- },
-
- {
- 11, 54, 54, -30, 54, 54, 54, 54, 54, 54,
- 54, 54, 54, 54, 54, 54, 54
- },
-
- {
- 11, -31, -31, -31, -31, -31, -31, 55, -31, -31,
- -31, -31, -31, -31, -31, -31, -31
- },
-
- {
- 11, -32, -32, -32, -32, -32, -32, -32, -32, -32,
- -32, -32, -32, -32, -32, -32, -32
- },
-
- {
- 11, -33, -33, -33, -33, -33, -33, -33, -33, -33,
- -33, -33, -33, -33, -33, -33, -33
- },
-
- {
- 11, -34, -34, -34, -34, -34, -34, -34, -34, -34,
- -34, 56, 57, 57, -34, -34, -34
-
- },
-
- {
- 11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
- -35, 57, 57, 57, -35, -35, -35
- },
-
- {
- 11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
- -36, -36, -36, -36, -36, -36, -36
- },
-
- {
- 11, -37, -37, 58, -37, -37, -37, -37, -37, -37,
- -37, -37, -37, -37, -37, -37, -37
- },
-
- {
- 11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
- -38, -38, -38, -38, -38, -38, 59
- },
-
- {
- 11, -39, 39, 40, -39, -39, 41, -39, -39, -39,
- -39, -39, -39, -39, -39, -39, -39
-
- },
-
- {
- 11, -40, -40, -40, -40, -40, -40, -40, -40, -40,
- -40, -40, -40, -40, -40, -40, -40
- },
-
- {
- 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 42
- },
-
- {
- 11, 42, 42, 43, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 42
- },
-
- {
- 11, -43, -43, -43, -43, -43, -43, -43, -43, -43,
- -43, -43, -43, -43, -43, -43, -43
- },
-
- {
- 11, -44, -44, -44, -44, -44, -44, -44, -44, -44,
- -44, -44, -44, 44, -44, -44, -44
-
- },
-
- {
- 11, 45, 45, -45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45
- },
-
- {
- 11, -46, 46, 47, -46, -46, -46, -46, -46, -46,
- -46, -46, -46, -46, -46, -46, -46
- },
-
- {
- 11, 48, -47, -47, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48
- },
-
- {
- 11, -48, -48, -48, -48, -48, -48, -48, -48, -48,
- -48, -48, -48, -48, -48, -48, -48
- },
-
- {
- 11, 49, 49, 50, 49, -49, 49, 49, -49, 49,
- 49, 49, 49, 49, 49, -49, 49
-
- },
-
- {
- 11, -50, -50, -50, -50, -50, -50, -50, -50, -50,
- -50, -50, -50, -50, -50, -50, -50
- },
-
- {
- 11, -51, -51, 52, -51, -51, -51, -51, -51, -51,
- -51, -51, -51, -51, -51, -51, -51
- },
-
- {
- 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
- -52, -52, -52, -52, -52, -52, -52
- },
-
- {
- 11, -53, -53, -53, -53, -53, -53, -53, -53, -53,
- -53, -53, -53, -53, -53, -53, -53
- },
-
- {
- 11, 54, 54, -54, 54, 54, 54, 54, 54, 54,
- 54, 54, 54, 54, 54, 54, 54
-
- },
-
- {
- 11, -55, -55, -55, -55, -55, -55, -55, -55, -55,
- -55, -55, -55, -55, -55, -55, -55
- },
-
- {
- 11, -56, -56, -56, -56, -56, -56, -56, -56, -56,
- -56, 60, 57, 57, -56, -56, -56
- },
-
- {
- 11, -57, -57, -57, -57, -57, -57, -57, -57, -57,
- -57, 57, 57, 57, -57, -57, -57
- },
-
- {
- 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
- -58, -58, -58, -58, -58, -58, -58
- },
-
- {
- 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
- -59, -59, -59, -59, -59, -59, -59
-
- },
-
- {
- 11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
- -60, 57, 57, 57, -60, -60, -60
- },
-
- } ;
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up zconftext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- zconfleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 33
-#define YY_END_OF_BUFFER 34
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[61] =
- { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 34, 5, 4, 2, 3, 7, 8, 6, 32, 29,
- 31, 24, 28, 27, 26, 22, 17, 13, 16, 20,
- 22, 11, 12, 19, 19, 14, 22, 22, 4, 2,
- 3, 3, 1, 6, 32, 29, 31, 30, 24, 23,
- 26, 25, 15, 20, 9, 19, 19, 21, 10, 18
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,
- 10, 1, 1, 1, 11, 12, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 1, 1, 1,
- 14, 1, 1, 1, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 1, 15, 1, 1, 13, 1, 13, 13, 13, 13,
-
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 1, 16, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-extern int zconf_flex_debug;
-int zconf_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *zconftext;
-#define YY_NO_INPUT 1
-
-/*
- * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
- */
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define LKC_DIRECT_LINK
-#include "lkc.h"
-
-#define START_STRSIZE 16
-
-static struct {
- struct file *file;
- int lineno;
-} current_pos;
-
-static char *text;
-static int text_size, text_asize;
-
-struct buffer {
- struct buffer *parent;
- YY_BUFFER_STATE state;
-};
-
-struct buffer *current_buf;
-
-static int last_ts, first_ts;
-
-static void zconf_endhelp(void);
-static void zconf_endfile(void);
-
-void new_string(void)
-{
- text = malloc(START_STRSIZE);
- text_asize = START_STRSIZE;
- text_size = 0;
- *text = 0;
-}
-
-void append_string(const char *str, int size)
-{
- int new_size = text_size + size + 1;
- if (new_size > text_asize) {
- new_size += START_STRSIZE - 1;
- new_size &= -START_STRSIZE;
- text = realloc(text, new_size);
- text_asize = new_size;
- }
- memcpy(text + text_size, str, size);
- text_size += size;
- text[text_size] = 0;
-}
-
-void alloc_string(const char *str, int size)
-{
- text = malloc(size + 1);
- memcpy(text, str, size);
- text[size] = 0;
-}
-
-#define INITIAL 0
-#define COMMAND 1
-#define HELP 2
-#define STRING 3
-#define PARAM 4
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int zconflex_destroy (void );
-
-int zconfget_debug (void );
-
-void zconfset_debug (int debug_flag );
-
-YY_EXTRA_TYPE zconfget_extra (void );
-
-void zconfset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *zconfget_in (void );
-
-void zconfset_in (FILE * in_str );
-
-FILE *zconfget_out (void );
-
-void zconfset_out (FILE * out_str );
-
-int zconfget_leng (void );
-
-char *zconfget_text (void );
-
-int zconfget_lineno (void );
-
-void zconfset_lineno (int line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int zconfwrap (void );
-#else
-extern int zconfwrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO fwrite( zconftext, zconfleng, 1, zconfout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- errno=0; \
- while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(zconfin); \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int zconflex (void);
-
-#define YY_DECL int zconflex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after zconftext and zconfleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
- int str = 0;
- int ts, i;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! zconfin )
- zconfin = stdin;
-
- if ( ! zconfout )
- zconfout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- zconfensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- zconf_create_buffer(zconfin,YY_BUF_SIZE );
- }
-
- zconf_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of zconftext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
- ++yy_cp;
-
- yy_current_state = -yy_current_state;
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
-case 1:
-/* rule 1 can match eol */
-case 2:
-/* rule 2 can match eol */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- return T_EOL;
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-{
- BEGIN(COMMAND);
-}
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-{
- unput(zconftext[0]);
- BEGIN(COMMAND);
-}
- YY_BREAK
-
-case 6:
-YY_RULE_SETUP
-{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
- BEGIN(PARAM);
- current_pos.file = current_file;
- current_pos.lineno = current_file->lineno;
- if (id && id->flags & TF_COMMAND) {
- zconflval.id = id;
- return id->token;
- }
- alloc_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD;
- }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-
- YY_BREAK
-case 8:
-/* rule 8 can match eol */
-YY_RULE_SETUP
-{
- BEGIN(INITIAL);
- current_file->lineno++;
- return T_EOL;
- }
- YY_BREAK
-
-case 9:
-YY_RULE_SETUP
-return T_AND;
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-return T_OR;
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-return T_OPEN_PAREN;
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-return T_CLOSE_PAREN;
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-return T_NOT;
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-return T_EQUAL;
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-return T_UNEQUAL;
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-{
- str = zconftext[0];
- new_string();
- BEGIN(STRING);
- }
- YY_BREAK
-case 17:
-/* rule 17 can match eol */
-YY_RULE_SETUP
-BEGIN(INITIAL); current_file->lineno++; return T_EOL;
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-/* ignore */
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
- if (id && id->flags & TF_PARAM) {
- zconflval.id = id;
- return id->token;
- }
- alloc_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD;
- }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-/* comment */
- YY_BREAK
-case 21:
-/* rule 21 can match eol */
-YY_RULE_SETUP
-current_file->lineno++;
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-
- YY_BREAK
-case YY_STATE_EOF(PARAM):
-{
- BEGIN(INITIAL);
- }
- YY_BREAK
-
-case 23:
-/* rule 23 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- append_string(zconftext, zconfleng);
- zconflval.string = text;
- return T_WORD_QUOTE;
- }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-{
- append_string(zconftext, zconfleng);
- }
- YY_BREAK
-case 25:
-/* rule 25 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- append_string(zconftext + 1, zconfleng - 1);
- zconflval.string = text;
- return T_WORD_QUOTE;
- }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-{
- append_string(zconftext + 1, zconfleng - 1);
- }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-{
- if (str == zconftext[0]) {
- BEGIN(PARAM);
- zconflval.string = text;
- return T_WORD_QUOTE;
- } else
- append_string(zconftext, 1);
- }
- YY_BREAK
-case 28:
-/* rule 28 can match eol */
-YY_RULE_SETUP
-{
- printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
- current_file->lineno++;
- BEGIN(INITIAL);
- return T_EOL;
- }
- YY_BREAK
-case YY_STATE_EOF(STRING):
-{
- BEGIN(INITIAL);
- }
- YY_BREAK
-
-case 29:
-YY_RULE_SETUP
-{
- ts = 0;
- for (i = 0; i < zconfleng; i++) {
- if (zconftext[i] == '\t')
- ts = (ts & ~7) + 8;
- else
- ts++;
- }
- last_ts = ts;
- if (first_ts) {
- if (ts < first_ts) {
- zconf_endhelp();
- return T_HELPTEXT;
- }
- ts -= first_ts;
- while (ts > 8) {
- append_string(" ", 8);
- ts -= 8;
- }
- append_string(" ", ts);
- }
- }
- YY_BREAK
-case 30:
-/* rule 30 can match eol */
-*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
-(yy_c_buf_p) = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up zconftext again */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- zconf_endhelp();
- return T_HELPTEXT;
- }
- YY_BREAK
-case 31:
-/* rule 31 can match eol */
-YY_RULE_SETUP
-{
- current_file->lineno++;
- append_string("\n", 1);
- }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-{
- while (zconfleng) {
- if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t'))
- break;
- zconfleng--;
- }
- append_string(zconftext, zconfleng);
- if (!first_ts)
- first_ts = last_ts;
- }
- YY_BREAK
-case YY_STATE_EOF(HELP):
-{
- zconf_endhelp();
- return T_HELPTEXT;
- }
- YY_BREAK
-
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(COMMAND):
-{
- if (current_file) {
- zconf_endfile();
- return T_EOL;
- }
- fclose(zconfin);
- yyterminate();
-}
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-YY_FATAL_ERROR( "flex scanner jammed" );
- YY_BREAK
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed zconfin at a new source and called
- * zconflex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( zconfwrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * zconftext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of zconflex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), (size_t) num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- zconfrestart(zconfin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
-
- yy_current_state = yy_nxt[yy_current_state][1];
- yy_is_jam = (yy_current_state <= 0);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up zconftext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- zconfrestart(zconfin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( zconfwrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve zconftext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void zconfrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- zconfensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- zconf_create_buffer(zconfin,YY_BUF_SIZE );
- }
-
- zconf_init_buffer(YY_CURRENT_BUFFER,input_file );
- zconf_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * zconfpop_buffer_state();
- * zconfpush_buffer_state(new_buffer);
- */
- zconfensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- zconf_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (zconfwrap()) processing, but the only time this flag
- * is looked at is after zconfwrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void zconf_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- zconf_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with zconf_create_buffer()
- *
- */
- void zconf_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- zconffree((void *) b->yy_ch_buf );
-
- zconffree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a zconfrestart() or at EOF.
- */
- static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- zconf_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then zconf_init_buffer was _probably_
- * called from zconfrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void zconf_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- zconf_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- zconfensure_buffer_stack();
-
- /* This block is copied from zconf_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from zconf_switch_to_buffer. */
- zconf_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void zconfpop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- zconf_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- zconf_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void zconfensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- zconf_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to zconflex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * zconf_scan_bytes() instead.
- */
-YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )
-{
-
- return zconf_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) zconfalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = zconf_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up zconftext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- zconftext[zconfleng] = (yy_hold_char); \
- (yy_c_buf_p) = zconftext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- zconfleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int zconfget_lineno (void)
-{
-
- return zconflineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *zconfget_in (void)
-{
- return zconfin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *zconfget_out (void)
-{
- return zconfout;
-}
-
-/** Get the length of the current token.
- *
- */
-int zconfget_leng (void)
-{
- return zconfleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *zconfget_text (void)
-{
- return zconftext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void zconfset_lineno (int line_number )
-{
-
- zconflineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see zconf_switch_to_buffer
- */
-void zconfset_in (FILE * in_str )
-{
- zconfin = in_str ;
-}
-
-void zconfset_out (FILE * out_str )
-{
- zconfout = out_str ;
-}
-
-int zconfget_debug (void)
-{
- return zconf_flex_debug;
-}
-
-void zconfset_debug (int bdebug )
-{
- zconf_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from zconflex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- zconfin = stdin;
- zconfout = stdout;
-#else
- zconfin = (FILE *) 0;
- zconfout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * zconflex_init()
- */
- return 0;
-}
-
-/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
-int zconflex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- zconf_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- zconfpop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- zconffree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * zconflex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *zconfalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *zconfrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void zconffree (void * ptr )
-{
- free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-void zconf_starthelp(void)
-{
- new_string();
- last_ts = first_ts = 0;
- BEGIN(HELP);
-}
-
-static void zconf_endhelp(void)
-{
- zconflval.string = text;
- BEGIN(INITIAL);
-}
-
-/*
- * Try to open specified file with following names:
- * ./name
- * $(srctree)/name
- * The latter is used when srctree is separate from objtree
- * when compiling the kernel.
- * Return NULL if file is not found.
- */
-FILE *zconf_fopen(const char *name)
-{
- char *env, fullname[PATH_MAX+1];
- FILE *f;
-
- f = fopen(name, "r");
- if (!f && name != NULL && name[0] != '/') {
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- f = fopen(fullname, "r");
- }
- }
- return f;
-}
-
-void zconf_initscan(const char *name)
-{
- zconfin = zconf_fopen(name);
- if (!zconfin) {
- printf("can't find file %s\n", name);
- exit(1);
- }
-
- current_buf = malloc(sizeof(*current_buf));
- memset(current_buf, 0, sizeof(*current_buf));
-
- current_file = file_lookup(name);
- current_file->lineno = 1;
- current_file->flags = FILE_BUSY;
-}
-
-void zconf_nextfile(const char *name)
-{
- struct file *file = file_lookup(name);
- struct buffer *buf = malloc(sizeof(*buf));
- memset(buf, 0, sizeof(*buf));
-
- current_buf->state = YY_CURRENT_BUFFER;
- zconfin = zconf_fopen(name);
- if (!zconfin) {
- printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
- exit(1);
- }
- zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
- buf->parent = current_buf;
- current_buf = buf;
-
- if (file->flags & FILE_BUSY) {
- printf("%s:%d: do not source '%s' from itself\n",
- zconf_curname(), zconf_lineno(), name);
- exit(1);
- }
- if (file->flags & FILE_SCANNED) {
- printf("%s:%d: file '%s' is already sourced from '%s'\n",
- zconf_curname(), zconf_lineno(), name,
- file->parent->name);
- exit(1);
- }
- file->flags |= FILE_BUSY;
- file->lineno = 1;
- file->parent = current_file;
- current_file = file;
-}
-
-static void zconf_endfile(void)
-{
- struct buffer *parent;
-
- current_file->flags |= FILE_SCANNED;
- current_file->flags &= ~FILE_BUSY;
- current_file = current_file->parent;
-
- parent = current_buf->parent;
- if (parent) {
- fclose(zconfin);
- zconf_delete_buffer(YY_CURRENT_BUFFER);
- zconf_switch_to_buffer(parent->state);
- }
- free(current_buf);
- current_buf = parent;
-}
-
-int zconf_lineno(void)
-{
- return current_pos.lineno;
-}
-
-char *zconf_curname(void)
-{
- return current_pos.file ? current_pos.file->name : "<none>";
-}
-
+++ /dev/null
-/* Copyright (C) 2007, 2008 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_SIGNALFD_H
-#define _SYS_SIGNALFD_H 1
-
-#define __need_sigset_t
-#include <signal.h>
-#include <stdint.h>
-
-
-struct signalfd_siginfo
-{
- uint32_t ssi_signo;
- int32_t ssi_errno;
- int32_t ssi_code;
- uint32_t ssi_pid;
- uint32_t ssi_uid;
- int32_t ssi_fd;
- uint32_t ssi_tid;
- uint32_t ssi_band;
- uint32_t ssi_overrun;
- uint32_t ssi_trapno;
- int32_t ssi_status;
- int32_t ssi_int;
- uint64_t ssi_ptr;
- uint64_t ssi_utime;
- uint64_t ssi_stime;
- uint64_t ssi_addr;
- uint8_t __pad[48];
-};
-
-/* Flags for signalfd. */
-#if defined __sparc__ || defined __sparc64__
-enum
- {
- SFD_CLOEXEC = 0x400000,
-# define SFD_CLOEXEC SFD_CLOEXEC
- SFD_NONBLOCK = 0x4000
-# define SFD_NONBLOCK SFD_NONBLOCK
- };
-
-#elif defined __alpha__
-enum
- {
- SFD_CLOEXEC = 010000000,
-# define SFD_CLOEXEC SFD_CLOEXEC
- SFD_NONBLOCK = 04
-# define SFD_NONBLOCK SFD_NONBLOCK
- };
-
-#else
-enum
- {
- SFD_CLOEXEC = 02000000,
-# define SFD_CLOEXEC SFD_CLOEXEC
- SFD_NONBLOCK = 04000
-# define SFD_NONBLOCK SFD_NONBLOCK
- };
-#endif
-
-__BEGIN_DECLS
-
-/* Request notification for delivery of signals in MASK to be
- performed using descriptor FD.*/
-extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
- __nonnull ((2)) __THROW;
-
-__END_DECLS
-
-#endif /* sys/signalfd.h */
+++ /dev/null
-/*
- *
- */
-
-#include <features.h>
-#include <errno.h>
-#include <netdb.h>
-
-#ifndef __UCLIBC_HAS_TLS__
-
-#undef errno
-#undef h_errno
-
-extern int h_errno;
-extern int errno;
-
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(h_errno)
-libc_hidden_proto(errno)
-#endif
-#endif
+++ /dev/null
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-/* Definitions relevant to functions that operate on `sigset_t's. */
-
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-
-#define BITS (_NSIG - 1)
-#define ELT(signo) (((signo) - 1) / BITS)
-#define MASK(signo) (1 << (((signo) - 1) % BITS))
-
-#undef sigemptyset
-#undef sigfillset
-#undef sigaddset
-#undef sigdelset
-#undef sigismember
+++ /dev/null
-/* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
- Based on code originally written by David Mosberger-Tang
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _LINUX_IA64_SYSDEP_H
-#define _LINUX_IA64_SYSDEP_H 1
-
-#include <features.h>
-#include <asm/unistd.h>
-
-#ifdef __ASSEMBLER__
-
-/* Macros to help writing .prologue directives in assembly code. */
-#define ASM_UNW_PRLG_RP 0x8
-#define ASM_UNW_PRLG_PFS 0x4
-#define ASM_UNW_PRLG_PSP 0x2
-#define ASM_UNW_PRLG_PR 0x1
-#define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
-
-#ifdef __STDC__
-#define C_LABEL(name) name :
-#else
-#define C_LABEL(name) name/**/:
-#endif
-
-#define CALL_MCOUNT
-
-#define ENTRY(name) \
- .text; \
- .align 32; \
- .proc C_SYMBOL_NAME(name); \
- .global C_SYMBOL_NAME(name); \
- C_LABEL(name) \
- CALL_MCOUNT
-
-#define LEAF(name) \
- .text; \
- .align 32; \
- .proc C_SYMBOL_NAME(name); \
- .global name; \
- C_LABEL(name)
-
-/* Mark the end of function SYM. */
-#undef END
-#define END(sym) .endp C_SYMBOL_NAME(sym)
-
-/* For Linux we can use the system call table in the header file
- /usr/include/asm/unistd.h
- of the kernel. But these symbols do not follow the SYS_* syntax
- so we have to redefine the `SYS_ify' macro here. */
-#undef SYS_ify
-#ifdef __STDC__
-# define SYS_ify(syscall_name) __NR_##syscall_name
-#else
-# define SYS_ify(syscall_name) __NR_/**/syscall_name
-#endif
-
-/* Linux uses a negative return value to indicate syscall errors, unlike
- most Unices, which use the condition codes' carry flag.
-
- Since version 2.1 the return value of a system call might be negative
- even if the call succeeded. E.g., the `lseek' system call might return
- a large offset. Therefore we must not anymore test for < 0, but test
- for a real error by making sure the value in %d0 is a real error
- number. Linus said he will make sure the no syscall returns a value
- in -1 .. -4095 as a valid result so we can savely test with -4095. */
-
-/* We don't want the label for the error handler to be visible in the symbol
- table when we define it here. */
-#define SYSCALL_ERROR_LABEL __syscall_error
-
-#undef PSEUDO
-#define PSEUDO(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name)); \
- cmp.eq p6,p0=-1,r10; \
-(p6) br.cond.spnt.few __syscall_error;
-
-#define DO_CALL_VIA_BREAK(num) \
- mov r15=num; \
- break __BREAK_SYSCALL
-
-#ifdef IA64_USE_NEW_STUB
-# ifdef SHARED
-# define DO_CALL(num) \
- .prologue; \
- adds r2 = SYSINFO_OFFSET, r13;; \
- ld8 r2 = [r2]; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- mov r15 = num; \
- mov b7 = r2; \
- br.call.sptk.many b6 = b7;; \
- .restore sp; \
- mov ar.pfs = r11; \
- .prologue; \
- .body
-# else /* !SHARED */
-# define DO_CALL(num) \
- .prologue; \
- mov r15 = num; \
- movl r2 = _dl_sysinfo;; \
- ld8 r2 = [r2]; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- mov b7 = r2; \
- br.call.sptk.many b6 = b7;; \
- .restore sp; \
- mov ar.pfs = r11; \
- .prologue; \
- .body
-# endif
-#else
-# define DO_CALL(num) DO_CALL_VIA_BREAK(num)
-#endif
-
-#undef PSEUDO_END
-#define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
-
-#undef PSEUDO_NOERRNO
-#define PSEUDO_NOERRNO(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name));
-
-#undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
-
-#undef PSEUDO_ERRVAL
-#define PSEUDO_ERRVAL(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name)); \
- cmp.eq p6,p0=-1,r10; \
-(p6) mov r10=r8;
-
-
-#undef PSEUDO_END_ERRVAL
-#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
-
-#undef END
-#define END(name) \
- .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
- .endp C_SYMBOL_NAME(name)
-
-#define ret br.ret.sptk.few b0
-#define ret_NOERRNO ret
-#define ret_ERRVAL ret
-
-#endif /* not __ASSEMBLER__ */
-
-#endif /* linux/ia64/sysdep.h */
+++ /dev/null
-/* Adapted from glibc's sysdeps/unix/mips/sysdep.h */
-
-/* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Brendan Kehoe (brendan@zen.org).
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifdef __ASSEMBLER__
-
-#include <sgidefs.h>
-#include <sys/regdef.h>
-
-#define ENTRY(name) \
- .globl name; \
- .align 2; \
- .ent name,0; \
- name/* use a comment rather than ## to workaround bug in gcc-3.4.x */:
-
-#undef END
-#define END(function) \
- .end function; \
- .size function,.-function
-
-#if _MIPS_SIM == _MIPS_SIM_ABI32 || _MIPS_SIM == _MIPS_SIM_ABIO64
-# define L(label) $L ## label
-#else
-# define L(label) .L ## label
-#endif
-
-#endif
+++ /dev/null
-/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_STATVFS_H
-# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
-#endif
-
-#include <bits/types.h> /* For __fsblkcnt_t and __fsfilcnt_t. */
-
-struct statvfs
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
- __fsfilcnt_t f_favail;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
-#endif
- unsigned long int f_fsid;
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statvfs64
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
- unsigned long int f_fsid;
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-#endif
-
-/* Definitions for the flag in `f_flag'. These definitions should be
- kept in sync which the definitions in <sys/mount.h>. */
-enum
-{
- ST_RDONLY = 1, /* Mount read-only. */
-#define ST_RDONLY ST_RDONLY
- ST_NOSUID = 2, /* Ignore suid and sgid bits. */
-#define ST_NOSUID ST_NOSUID
-#ifdef __USE_GNU
- ST_NODEV = 4, /* Disallow access to device special files. */
-# define ST_NODEV ST_NODEV
- ST_NOEXEC = 8, /* Disallow program execution. */
-# define ST_NOEXEC ST_NOEXEC
- ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
-# define ST_SYNCHRONOUS ST_SYNCHRONOUS
- ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
-# define ST_MANDLOCK ST_MANDLOCK
- ST_WRITE = 128, /* Write on file/directory/symlink. */
-# define ST_WRITE ST_WRITE
- ST_APPEND = 256, /* Append-only file. */
-# define ST_APPEND ST_APPEND
- ST_IMMUTABLE = 512, /* Immutable file. */
-# define ST_IMMUTABLE ST_IMMUTABLE
- ST_NOATIME = 1024, /* Do not update access times. */
-# define ST_NOATIME ST_NOATIME
- ST_NODIRATIME /* Do not update directory access times. */
-# define ST_NODIRATIME ST_NODIRATIME
-#endif /* Use GNU. */
-};
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * _mmap() for uClibc
- *
- * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
- *
- * GNU Library General Public License (LGPL) version 2 or later.
- */
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-#if defined (__NR_mmap) || defined (__NR_mmap2)
-
-libc_hidden_proto(mmap)
-#if defined (__UCLIBC_MMAP_HAS_6_ARGS__) && defined (__NR_mmap)
-#define __NR__mmap __NR_mmap
-static __inline__ _syscall6 (__ptr_t, _mmap, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset)
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, offset);
-}
-
-#elif defined (__NR_mmap2)
-#define __NR__mmap __NR_mmap2
-
-#ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-#endif
-
-static __inline__ _syscall6 (__ptr_t, _mmap, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset);
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- /* check if offset is page aligned */
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
- {
- __set_errno(EINVAL);
- return MAP_FAILED;
- }
-#ifdef __USE_FILE_OFFSET64
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, ((__u_quad_t) offset >> MMAP2_PAGE_SHIFT));
-#else
- return (__ptr_t) _mmap (addr, len, prot, flags,
- fd, ((__u_long) offset >> MMAP2_PAGE_SHIFT));
-#endif
-}
-#elif defined (__NR_mmap)
-# define __NR__mmap __NR_mmap
-static __inline__ _syscall1(__ptr_t, _mmap, unsigned long *, buffer)
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- unsigned long buffer[6];
-
- buffer[0] = (unsigned long) addr;
- buffer[1] = (unsigned long) len;
- buffer[2] = (unsigned long) prot;
- buffer[3] = (unsigned long) flags;
- buffer[4] = (unsigned long) fd;
- buffer[5] = (unsigned long) offset;
- return (__ptr_t) _mmap(buffer);
-}
-#endif
-libc_hidden_def (mmap)
-#else
-# error "Your architecture doesn't seem to provide mmap() !?"
-#endif
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for ARM uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#if defined __NR_arm_fadvise64_64
-
-#define HIGH_BITS(x) (sizeof(x) > 4 ? (x) >> 32 : 0)
-
-/* Was named __libc_posix_fadvise for some inexplicable reason.
-** google says only uclibc has *__libc*_posix_fadviseXXX,
-** so it cannot be compat with anything.
-**
-** Remove this comment and one at the end after 0.9.31
-*/
-
-/* This is for the ARM version of fadvise64_64 which swaps the params
- * * about to avoid having ABI compat issues
- * */
-#define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
-int posix_fadvise(int fd, off_t offset, off_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR (HIGH_BITS(offset), (long)offset),
- __LONG_LONG_PAIR (HIGH_BITS(len), (long)len));
-
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-
-/* weak_alias(__libc_posix_fadvise, posix_fadvise); */
-
-#else
-
-int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
-{
- return ENOSYS;
-}
-
-#endif
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for ARM uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-#if defined __NR_arm_fadvise64_64
-
-/* Was named __libc_posix_fadvise64 for some inexplicable reason.
-** google says only uclibc has *__libc*_posix_fadviseXXX,
-** so it cannot be compat with anything.
-**
-** Remove this comment and one at the end after 0.9.31
-*/
-
-/* This is for the ARM version of fadvise64_64 which swaps the params
- * about to avoid having ABI compat issues
- */
-#define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
- __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-
-/* weak_alias(__libc_posix_fadvise64, posix_fadvise64); */
-
-#else
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- return ENOSYS;
-}
-
-#endif
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-#ifndef _BITS_UCLIBC_ERRNO_H
-#define _BITS_UCLIBC_ERRNO_H 1
-
-#ifdef IS_IN_rtld
-# undef errno
-# define errno _dl_errno
-extern int _dl_errno; /* attribute_hidden; */
-#elif defined __UCLIBC_HAS_THREADS__
-# include <tls.h>
-# if defined USE___THREAD && USE___THREAD
-# undef errno
-# ifndef NOT_IN_libc
-# define errno __libc_errno
-# else
-# define errno errno
-# endif
-extern __thread int errno attribute_tls_model_ie;
-# endif /* USE___THREAD */
-#endif /* IS_IN_rtld */
-
-#define __set_errno(val) (errno = (val))
-
-#ifndef __ASSEMBLER__
-extern int *__errno_location (void) __THROW __attribute__ ((__const__))
-# ifdef IS_IN_rtld
- attribute_hidden
-# endif
-;
-# if defined __UCLIBC_HAS_THREADS__
-# include <tls.h>
-# if defined USE___THREAD && USE___THREAD
-libc_hidden_proto(__errno_location)
-# endif
-# endif
-
-#endif /* !__ASSEMBLER__ */
-
-#endif
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * Common header file for uClibc syscalls
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <endian.h>
-
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * being renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
-
-#include <bits/kernel_types.h>
+++ /dev/null
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include "sysdep.h"
-
-#define __NR___libc_fork __NR_fork
-SYSCALL__ (__libc_fork, 0)
- /* R1 is now 0 for the parent and 1 for the child. Decrement it to
- make it -1 (all bits set) for the parent, and 0 (no bits set)
- for the child. Then AND it with R0, so the parent gets
- R0&-1==R0, and the child gets R0&0==0. */
- /* i dunno what the blurb above is useful for. we just return. */
-__asm__("ret\n\tnop");
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
+++ /dev/null
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <errno.h>
-
-#define __NR___vfork __NR_vfork
-attribute_hidden _syscall0(pid_t, __vfork)
-weak_alias(__vfork,vfork)
-libc_hidden_weak(vfork)
+++ /dev/null
-/* Copyright (C) 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Daniel Jacobowitz <dan@debian.org>, 1999.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-/* Massivly hacked up for uClibc by Erik Andersen */
-
-/* Extracted from ../common/mmap64.c by Alexandre Oliva <aoliva@redhat.com>
-
- We don't want to use the old mmap interface. */
-
-#include <features.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <sys/mman.h>
-
-
-#define __NR___syscall_mmap2 __NR_mmap2
-static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
- size_t, len, int, prot, int, flags, int, fd, off_t, offset)
-
-/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
-
-__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
-{
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
- __set_errno (EINVAL);
- return MAP_FAILED;
- }
- return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
-}
-libc_hidden_def(mmap)
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * mmap() for uClibc/x86_64
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-
-_syscall6(void *, mmap, void *, start, size_t, length, int, prot,
- int, flags, int, fd, off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/*
- * include/bits/select.h -- fd_set operations
- *
- * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
- * Copyright (C) 2001 NEC Corporation
- * Copyright (C) 2001 Miles Bader <miles@gnu.org>
- * Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- *
- * This file is subject to the terms and conditions of the GNU Lesser
- * General Public License. See the file COPYING.LIB in the main
- * directory of this archive for more details.
- */
-
-#ifndef _SYS_SELECT_H
-# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
-#endif
-
-#ifdef __GNUC__
-
-/* We don't use `memset' because this would require a prototype and
- the array isn't too big. */
-#define __FD_ZERO(s) \
- do { \
- unsigned int __i; \
- fd_set *__arr = (s); \
- for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
- __FDS_BITS (__arr)[__i] = 0; \
- } while (0)
-
-#define __FD_SET(fd, s) \
- do { \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- *__addr |= (1 << __fd); \
- } while (0)
-
-#define __FD_CLR(fd, s) \
- do { \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- *__addr &= ~(1 << __fd); \
- } while (0)
-
-#define __FD_ISSET(fd, s) \
- ({ \
- int __fd = (fd); \
- unsigned int *__addr = (unsigned int *)&__FDS_BITS (s); \
- int res; \
- res = (*__addr & (1 << fd)) ? 1 : 0; \
- })
-
-#else /* !__GNUC__ */
-
-#define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d))
-#define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d))
-#define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0)
-
-#endif /* __GNUC__ */
+++ /dev/null
-/* Use new style mmap for microblaze */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/* System-specific socket constants and types. Linux/MIPS version.
- Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004, 2005, 2006
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef __BITS_SOCKET_H
-#define __BITS_SOCKET_H
-
-#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
-# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
-#endif
-
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
-#include <limits.h>
-#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
-/* Types of sockets. */
-enum __socket_type
-{
- SOCK_DGRAM = 1, /* Connectionless, unreliable datagrams
- of fixed maximum length. */
-#define SOCK_DGRAM SOCK_DGRAM
- SOCK_STREAM = 2, /* Sequenced, reliable, connection-based
- byte streams. */
-#define SOCK_STREAM SOCK_STREAM
- SOCK_RAW = 3, /* Raw protocol interface. */
-#define SOCK_RAW SOCK_RAW
- SOCK_RDM = 4, /* Reliably-delivered messages. */
-#define SOCK_RDM SOCK_RDM
- SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
- datagrams of fixed maximum length. */
-#define SOCK_SEQPACKET SOCK_SEQPACKET
- SOCK_DCCP = 6,
-#define SOCK_DCCP SOCK_DCCP /* Datagram Congestion Control Protocol. */
- SOCK_PACKET = 10, /* Linux specific way of getting packets
- at the dev level. For writing rarp and
- other similar things on the user level. */
-#define SOCK_PACKET SOCK_PACKET
- /* Flags to be ORed into the type parameter of socket and socketpair and
- used for the flags parameter of paccept. */
-
- SOCK_CLOEXEC = 02000000, /* Atomically set close-on-exec flag for the
- new descriptor(s). */
-#define SOCK_CLOEXEC SOCK_CLOEXEC
- SOCK_NONBLOCK = 0200 /* Atomically mark descriptor(s) as
- non-blocking. */
-#define SOCK_NONBLOCK SOCK_NONBLOCK
-};
-
-/* Protocol families. */
-#define PF_UNSPEC 0 /* Unspecified. */
-#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
-#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
-#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
-#define PF_INET 2 /* IP protocol family. */
-#define PF_AX25 3 /* Amateur Radio AX.25. */
-#define PF_IPX 4 /* Novell Internet Protocol. */
-#define PF_APPLETALK 5 /* Appletalk DDP. */
-#define PF_NETROM 6 /* Amateur radio NetROM. */
-#define PF_BRIDGE 7 /* Multiprotocol bridge. */
-#define PF_ATMPVC 8 /* ATM PVCs. */
-#define PF_X25 9 /* Reserved for X.25 project. */
-#define PF_INET6 10 /* IP version 6. */
-#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */
-#define PF_DECnet 12 /* Reserved for DECnet project. */
-#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */
-#define PF_SECURITY 14 /* Security callback pseudo AF. */
-#define PF_KEY 15 /* PF_KEY key management API. */
-#define PF_NETLINK 16
-#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
-#define PF_PACKET 17 /* Packet family. */
-#define PF_ASH 18 /* Ash. */
-#define PF_ECONET 19 /* Acorn Econet. */
-#define PF_ATMSVC 20 /* ATM SVCs. */
-#define PF_SNA 22 /* Linux SNA Project */
-#define PF_IRDA 23 /* IRDA sockets. */
-#define PF_PPPOX 24 /* PPPoX sockets. */
-#define PF_WANPIPE 25 /* Wanpipe API sockets. */
-#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
-
-/* Address families. */
-#define AF_UNSPEC PF_UNSPEC
-#define AF_LOCAL PF_LOCAL
-#define AF_UNIX PF_UNIX
-#define AF_FILE PF_FILE
-#define AF_INET PF_INET
-#define AF_AX25 PF_AX25
-#define AF_IPX PF_IPX
-#define AF_APPLETALK PF_APPLETALK
-#define AF_NETROM PF_NETROM
-#define AF_BRIDGE PF_BRIDGE
-#define AF_ATMPVC PF_ATMPVC
-#define AF_X25 PF_X25
-#define AF_INET6 PF_INET6
-#define AF_ROSE PF_ROSE
-#define AF_DECnet PF_DECnet
-#define AF_NETBEUI PF_NETBEUI
-#define AF_SECURITY PF_SECURITY
-#define AF_KEY PF_KEY
-#define AF_NETLINK PF_NETLINK
-#define AF_ROUTE PF_ROUTE
-#define AF_PACKET PF_PACKET
-#define AF_ASH PF_ASH
-#define AF_ECONET PF_ECONET
-#define AF_ATMSVC PF_ATMSVC
-#define AF_SNA PF_SNA
-#define AF_IRDA PF_IRDA
-#define AF_PPPOX PF_PPPOX
-#define AF_WANPIPE PF_WANPIPE
-#define AF_BLUETOOTH PF_BLUETOOTH
-#define AF_MAX PF_MAX
-
-/* Socket level values. Others are defined in the appropriate headers.
-
- XXX These definitions also should go into the appropriate headers as
- far as they are available. */
-#define SOL_RAW 255
-#define SOL_DECNET 261
-#define SOL_X25 262
-#define SOL_PACKET 263
-#define SOL_ATM 264 /* ATM layer (cell level). */
-#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */
-#define SOL_IRDA 266
-
-/* Maximum queue length specifiable by listen. */
-#define SOMAXCONN 128
-
-/* Get the definition of the macro to define the common sockaddr members. */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address. */
-struct sockaddr
- {
- __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
- char sa_data[14]; /* Address data. */
- };
-
-
-/* Structure large enough to hold any socket address (with the historical
- exception of AF_UNIX). We reserve 128 bytes. */
-#define __ss_aligntype unsigned long int
-#define _SS_SIZE 128
-#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
-
-struct sockaddr_storage
- {
- __SOCKADDR_COMMON (ss_); /* Address family, etc. */
- __ss_aligntype __ss_align; /* Force desired alignment. */
- char __ss_padding[_SS_PADSIZE];
- };
-
-
-/* Bits in the FLAGS argument to `send', `recv', et al. */
-enum
- {
- MSG_OOB = 0x01, /* Process out-of-band data. */
-#define MSG_OOB MSG_OOB
- MSG_PEEK = 0x02, /* Peek at incoming messages. */
-#define MSG_PEEK MSG_PEEK
- MSG_DONTROUTE = 0x04, /* Don't use local routing. */
-#define MSG_DONTROUTE MSG_DONTROUTE
-#ifdef __USE_GNU
- /* DECnet uses a different name. */
- MSG_TRYHARD = MSG_DONTROUTE,
-# define MSG_TRYHARD MSG_DONTROUTE
-#endif
- MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
-#define MSG_CTRUNC MSG_CTRUNC
- MSG_PROXY = 0x10, /* Supply or ask second address. */
-#define MSG_PROXY MSG_PROXY
- MSG_TRUNC = 0x20,
-#define MSG_TRUNC MSG_TRUNC
- MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
-#define MSG_DONTWAIT MSG_DONTWAIT
- MSG_EOR = 0x80, /* End of record. */
-#define MSG_EOR MSG_EOR
- MSG_WAITALL = 0x100, /* Wait for a full request. */
-#define MSG_WAITALL MSG_WAITALL
- MSG_FIN = 0x200,
-#define MSG_FIN MSG_FIN
- MSG_SYN = 0x400,
-#define MSG_SYN MSG_SYN
- MSG_CONFIRM = 0x800, /* Confirm path validity. */
-#define MSG_CONFIRM MSG_CONFIRM
- MSG_RST = 0x1000,
-#define MSG_RST MSG_RST
- MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
-#define MSG_ERRQUEUE MSG_ERRQUEUE
- MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
-#define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000, /* Sender will send more. */
-#define MSG_MORE MSG_MORE
- MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/
-#define MSG_WAITFORONE MSG_WAITFORONE
-
- MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file
- descriptor received through
- SCM_RIGHTS. */
-#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC
- };
-
-
-/* Structure describing messages sent by
- `sendmsg' and received by `recvmsg'. */
-/* Note: do not change these members to match glibc; these match the
- SuSv3 spec already (e.g. msg_iovlen/msg_controllen).
- http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html */
-/* Note: linux kernel uses __kernel_size_t (which is 8bytes on 64bit
- platforms, and 4bytes on 32bit platforms) for msg_iovlen/msg_controllen */
-struct msghdr
- {
- void *msg_name; /* Address to send to/receive from. */
- socklen_t msg_namelen; /* Length of address data. */
-
- struct iovec *msg_iov; /* Vector of data to send/receive into. */
-#if __WORDSIZE == 32
- int msg_iovlen; /* Number of elements in the vector. */
-#else
- size_t msg_iovlen; /* Number of elements in the vector. */
-#endif
-
- void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
-#if __WORDSIZE == 32
- socklen_t msg_controllen; /* Ancillary data buffer length. */
-#else
- size_t msg_controllen; /* Ancillary data buffer length. */
-#endif
-
- int msg_flags; /* Flags on received message. */
- };
-
-/* Structure used for storage of ancillary data object information. */
-struct cmsghdr
- {
- size_t cmsg_len; /* Length of data in cmsg_data plus length
- of cmsghdr structure. */
- int cmsg_level; /* Originating protocol. */
- int cmsg_type; /* Protocol specific type. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
- __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
-#endif
- };
-
-/* Ancillary data object manipulation macros. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
-# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
-#else
-# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
-#endif
-#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
-#define CMSG_FIRSTHDR(mhdr) \
- ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
- ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
-#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
- & (size_t) ~(sizeof (size_t) - 1))
-#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
- + CMSG_ALIGN (sizeof (struct cmsghdr)))
-#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
-
-extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
- struct cmsghdr *__cmsg) __THROW;
-libc_hidden_proto(__cmsg_nxthdr)
-#ifdef __USE_EXTERN_INLINES
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
-# endif
-_EXTERN_INLINE struct cmsghdr *
-__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
-{
- if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
- return 0;
-
- __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
- + CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return 0;
- return __cmsg;
-}
-#endif /* Use `extern inline'. */
-
-/* Socket level message types. This must match the definitions in
- <linux/socket.h>. */
-enum
- {
- SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
-#define SCM_RIGHTS SCM_RIGHTS
-#ifdef __USE_BSD
- , SCM_CREDENTIALS = 0x02 /* Credentials passing. */
-# define SCM_CREDENTIALS SCM_CREDENTIALS
-#endif
- };
-
-/* User visible structure for SCM_CREDENTIALS message */
-
-struct ucred
-{
- pid_t pid; /* PID of sending process. */
- uid_t uid; /* UID of sending process. */
- gid_t gid; /* GID of sending process. */
-};
-
-/* Get socket manipulation related informations from kernel headers. */
-#ifndef __GLIBC__
-#define __GLIBC__ 2
-#include <asm/socket.h>
-#undef __GLIBC__
-#else
-#include <asm/socket.h>
-#endif
-
-
-/* Structure used to manipulate the SO_LINGER option. */
-struct linger
- {
- int l_onoff; /* Nonzero to linger on close. */
- int l_linger; /* Time to linger. */
- };
-
-#endif /* bits/socket.h */
+++ /dev/null
-/* Use new style mmap for mips */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-
-#if 0
-/* For now, leave mmap using mmap1 since mmap2 seems
- * to have issues (i.e. it doesn't work 100% properly).
- */
-#ifdef __NR_mmap2
-# undef __NR_mmap
-# define __NR_mmap __NR_mmap2
-#endif
-#endif
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/* Provide kernel hint to read ahead.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-#include <_lfs_64.h>
-# ifdef __NR_readahead
-
-ssize_t readahead(int fd, off64_t offset, size_t count)
-{
-# if _MIPS_SIM == _ABIO32
- return INLINE_SYSCALL (readahead, 5, fd, 0,
- __LONG_LONG_PAIR ((off_t) (offset >> 32), (off_t) offset),
- count);
-# else /* N32 || N64 */
- return INLINE_SYSCALL (readahead, 3, fd, offset, count);
-# endif
-}
-
-# endif
-#endif
+++ /dev/null
-/* Copyright (C) 2004 Erik Andersen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * The GNU C Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the GNU C Library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA.
- */
-
-/* Supply an architecture specific value for PAGE_SIZE and friends. */
-
-#ifndef _UCLIBC_PAGE_H
-#define _UCLIBC_PAGE_H
-
-/* PAGE_SHIFT determines the page size -- in this case 4096 */
-#define PAGE_SHIFT (12)
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-#endif /* _UCLIBC_PAGE_H */
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __NR_fadvise64
-#define __NR_posix_fadvise __NR_fadvise64
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
- INTERNAL_SYSCALL_DECL(err);
- int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 6, fd, 0,
- __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-
-#if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || !defined _syscall6)
-strong_alias(posix_fadvise,posix_fadvise64)
-#endif
-
-#else
-int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
-{
-#warning This is not correct as far as SUSv3 is concerned.
- return ENOSYS;
-}
-#endif
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-#ifdef __NR_fadvise64_64
-
-/* 64 bit implementation is cake ... or more like pie ... */
-#if __WORDSIZE == 64
-
-#define __NR_posix_fadvise64 __NR_fadvise64_64
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- if (len != (off_t) len)
- return EOVERFLOW;
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (posix_fadvise64, err, 6, fd, 0,
- __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
- (off_t) len, advise);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
-
-/* 32 bit implementation is kind of a pita */
-#elif __WORDSIZE == 32
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR((long) (offset >> 32), (long) offset ),
- __LONG_LONG_PAIR((long) (len >> 32), (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
-
-#else
-#error your machine is neither 32 bit or 64 bit ... it must be magical
-#endif
-
-#elif !defined __NR_fadvise64
-/* This is declared as a strong alias in posix_fadvise.c if __NR_fadvise64
- * is defined.
- */
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
-#warning This is not correct as far as SUSv3 is concerned.
- return ENOSYS;
-}
-#endif /* __NR_fadvise64_64 */
-#endif /* __UCLIBC_HAS_LFS__ */
+++ /dev/null
-/* vi: set sw=4 ts=4:
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/* Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <endian.h>
-
-#ifndef __UCLIBC_HAS_LFS__
-# define off64_t off_t
-#endif
-
-#ifdef __NR_pread
-extern __typeof(pread) __libc_pread;
-# define __NR___syscall_pread __NR_pread
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd,
- void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pread */
-
-
-#ifdef __NR_pwrite
-extern __typeof(pwrite) __libc_pwrite;
-# define __NR___syscall_pwrite __NR_pwrite
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd,
- const void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pwrite64) __libc_pwrite64;
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek (fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
- return result;
-}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
-
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset);
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__fake_pread_write(fd, buf, count, offset, 0));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset);
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return(__fake_pread_write64(fd, buf, count, offset, 0));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
-
-
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset);
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return(__fake_pread_write(fd, (void*)buf, count, offset, 1));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset);
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return(__fake_pread_write64(fd, (void*)buf, count, offset, 1));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
+++ /dev/null
-/* Copyright (C) 1991, 92, 94, 95, 97, 98, 2000 Free Software Foundation, Inc.
- Copyright (C) 2001 Hewlett-Packard Australia
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Library General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
- details.
-
- You should have received a copy of the GNU Library General Public License
- along with this program; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Derived in part from the Linux-8086 C library, the GNU C Library, and several
- other sundry sources. Files within this library are copyright by their
- respective copyright holders.
-*/
-
-#include <stddef.h>
-#include <setjmp.h>
-#include <signal.h>
-
-libc_hidden_proto(sigprocmask)
-
-extern int __longjmp(char *env, int val);
-libc_hidden_proto(__longjmp)
-
-extern void _longjmp_unwind (jmp_buf env, int val);
-
-
-/* Set the signal mask to the one specified in ENV, and jump
- to the position specified in ENV, causing the setjmp
- call there to return VAL, or 1 if VAL is 0. */
-void __libc_siglongjmp (sigjmp_buf env, int val)
-{
- /* Perform any cleanups needed by the frames being unwound. */
-
- _longjmp_unwind (env, val);
-
- if (env[0].__mask_was_saved)
- /* Restore the saved signal mask. */
- (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
- (sigset_t *) NULL);
-
- /* Call the machine-dependent function to restore machine state. */
- __longjmp ((char *) env[0].__jmpbuf, val ?: 1);
-}
-
-__asm__(".weak longjmp; longjmp = __libc_siglongjmp");
-__asm__(".weak _longjmp; _longjmp = __libc_siglongjmp");
-__asm__(".weak siglongjmp; siglongjmp = __libc_siglongjmp");
-strong_alias(__libc_siglongjmp, __libc_longjmp)
+++ /dev/null
-/* Copyright (C) 2001 Hewlett-Packard
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU Library General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your option) any
- later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
- details.
-
- You should have received a copy of the GNU Library General Public License
- along with this program; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Derived in part from the Linux-8086 C library, the GNU C Library, and several
- other sundry sources. Files within this library are copyright by their
- respective copyright holders.
-*/
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-
-
-#ifdef HIOS
-# define __SH_SYSCALL6_TRAPA 0x2E
-#endif
-
-#include <sys/syscall.h>
-
-_syscall6(__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/* System-specific socket constants and types. Linux version.
- Copyright (C) 1991,1992,1994-2001,2004,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef __BITS_SOCKET_H
-#define __BITS_SOCKET_H
-
-#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
-# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
-#endif
-
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
-#include <limits.h>
-#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
-/* Types of sockets. */
-enum __socket_type
-{
- SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
- byte streams. */
-#define SOCK_STREAM SOCK_STREAM
- SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
- of fixed maximum length. */
-#define SOCK_DGRAM SOCK_DGRAM
- SOCK_RAW = 3, /* Raw protocol interface. */
-#define SOCK_RAW SOCK_RAW
- SOCK_RDM = 4, /* Reliably-delivered messages. */
-#define SOCK_RDM SOCK_RDM
- SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
- datagrams of fixed maximum length. */
-#define SOCK_SEQPACKET SOCK_SEQPACKET
- SOCK_PACKET = 10 /* Linux specific way of getting packets
- at the dev level. For writing rarp and
- other similar things on the user level. */
-#define SOCK_PACKET SOCK_PACKET
-};
-
-/* Protocol families. */
-#define PF_UNSPEC 0 /* Unspecified. */
-#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */
-#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */
-#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */
-#define PF_INET 2 /* IP protocol family. */
-#define PF_AX25 3 /* Amateur Radio AX.25. */
-#define PF_IPX 4 /* Novell Internet Protocol. */
-#define PF_APPLETALK 5 /* Appletalk DDP. */
-#define PF_NETROM 6 /* Amateur radio NetROM. */
-#define PF_BRIDGE 7 /* Multiprotocol bridge. */
-#define PF_ATMPVC 8 /* ATM PVCs. */
-#define PF_X25 9 /* Reserved for X.25 project. */
-#define PF_INET6 10 /* IP version 6. */
-#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */
-#define PF_DECnet 12 /* Reserved for DECnet project. */
-#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */
-#define PF_SECURITY 14 /* Security callback pseudo AF. */
-#define PF_KEY 15 /* PF_KEY key management API. */
-#define PF_NETLINK 16
-#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */
-#define PF_PACKET 17 /* Packet family. */
-#define PF_ASH 18 /* Ash. */
-#define PF_ECONET 19 /* Acorn Econet. */
-#define PF_ATMSVC 20 /* ATM SVCs. */
-#define PF_SNA 22 /* Linux SNA Project */
-#define PF_IRDA 23 /* IRDA sockets. */
-#define PF_PPPOX 24 /* PPPoX sockets. */
-#define PF_WANPIPE 25 /* Wanpipe API sockets. */
-#define PF_BLUETOOTH 31 /* Bluetooth sockets. */
-#define PF_MAX 32 /* For now.. */
-
-/* Address families. */
-#define AF_UNSPEC PF_UNSPEC
-#define AF_LOCAL PF_LOCAL
-#define AF_UNIX PF_UNIX
-#define AF_FILE PF_FILE
-#define AF_INET PF_INET
-#define AF_AX25 PF_AX25
-#define AF_IPX PF_IPX
-#define AF_APPLETALK PF_APPLETALK
-#define AF_NETROM PF_NETROM
-#define AF_BRIDGE PF_BRIDGE
-#define AF_ATMPVC PF_ATMPVC
-#define AF_X25 PF_X25
-#define AF_INET6 PF_INET6
-#define AF_ROSE PF_ROSE
-#define AF_DECnet PF_DECnet
-#define AF_NETBEUI PF_NETBEUI
-#define AF_SECURITY PF_SECURITY
-#define AF_KEY PF_KEY
-#define AF_NETLINK PF_NETLINK
-#define AF_ROUTE PF_ROUTE
-#define AF_PACKET PF_PACKET
-#define AF_ASH PF_ASH
-#define AF_ECONET PF_ECONET
-#define AF_ATMSVC PF_ATMSVC
-#define AF_SNA PF_SNA
-#define AF_IRDA PF_IRDA
-#define AF_PPPOX PF_PPPOX
-#define AF_WANPIPE PF_WANPIPE
-#define AF_BLUETOOTH PF_BLUETOOTH
-#define AF_MAX PF_MAX
-
-/* Socket level values. Others are defined in the appropriate headers.
-
- XXX These definitions also should go into the appropriate headers as
- far as they are available. */
-#define SOL_RAW 255
-#define SOL_DECNET 261
-#define SOL_X25 262
-#define SOL_PACKET 263
-#define SOL_ATM 264 /* ATM layer (cell level). */
-#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */
-#define SOL_IRDA 266
-
-/* Maximum queue length specifiable by listen. */
-#define SOMAXCONN 128
-
-/* Get the definition of the macro to define the common sockaddr members. */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address. */
-struct sockaddr
- {
- __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
- char sa_data[14]; /* Address data. */
- };
-
-
-/* Structure large enough to hold any socket address (with the historical
- exception of AF_UNIX). We reserve 128 bytes. */
-#if ULONG_MAX > 0xffffffff
-# define __ss_aligntype __uint64_t
-#else
-# define __ss_aligntype __uint32_t
-#endif
-#define _SS_SIZE 128
-#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype)))
-
-struct sockaddr_storage
- {
- __SOCKADDR_COMMON (ss_); /* Address family, etc. */
- __ss_aligntype __ss_align; /* Force desired alignment. */
- char __ss_padding[_SS_PADSIZE];
- };
-
-
-/* Bits in the FLAGS argument to `send', `recv', et al. */
-enum
- {
- MSG_OOB = 0x01, /* Process out-of-band data. */
-#define MSG_OOB MSG_OOB
- MSG_PEEK = 0x02, /* Peek at incoming messages. */
-#define MSG_PEEK MSG_PEEK
- MSG_DONTROUTE = 0x04, /* Don't use local routing. */
-#define MSG_DONTROUTE MSG_DONTROUTE
-#ifdef __USE_GNU
- /* DECnet uses a different name. */
- MSG_TRYHARD = MSG_DONTROUTE,
-# define MSG_TRYHARD MSG_DONTROUTE
-#endif
- MSG_CTRUNC = 0x08, /* Control data lost before delivery. */
-#define MSG_CTRUNC MSG_CTRUNC
- MSG_PROXY = 0x10, /* Supply or ask second address. */
-#define MSG_PROXY MSG_PROXY
- MSG_TRUNC = 0x20,
-#define MSG_TRUNC MSG_TRUNC
- MSG_DONTWAIT = 0x40, /* Nonblocking IO. */
-#define MSG_DONTWAIT MSG_DONTWAIT
- MSG_EOR = 0x80, /* End of record. */
-#define MSG_EOR MSG_EOR
- MSG_WAITALL = 0x100, /* Wait for a full request. */
-#define MSG_WAITALL MSG_WAITALL
- MSG_FIN = 0x200,
-#define MSG_FIN MSG_FIN
- MSG_SYN = 0x400,
-#define MSG_SYN MSG_SYN
- MSG_CONFIRM = 0x800, /* Confirm path validity. */
-#define MSG_CONFIRM MSG_CONFIRM
- MSG_RST = 0x1000,
-#define MSG_RST MSG_RST
- MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */
-#define MSG_ERRQUEUE MSG_ERRQUEUE
- MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */
-#define MSG_NOSIGNAL MSG_NOSIGNAL
- MSG_MORE = 0x8000 /* Sender will send more. */
-#define MSG_MORE MSG_MORE
- };
-
-
-/* Structure describing messages sent by
- `sendmsg' and received by `recvmsg'. */
-/* Note: do not change these members to match glibc; these match the
- SuSv3 spec already (e.g. msg_iovlen/msg_controllen).
- http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html */
-/* Note: linux kernel uses __kernel_size_t (which is 8bytes on 64bit
- platforms, and 4bytes on 32bit platforms) for msg_iovlen/msg_controllen */
-struct msghdr
- {
- void *msg_name; /* Address to send to/receive from. */
- socklen_t msg_namelen; /* Length of address data. */
-
- struct iovec *msg_iov; /* Vector of data to send/receive into. */
-#if __WORDSIZE == 32
- int msg_iovlen; /* Number of elements in the vector. */
-#else
- size_t msg_iovlen; /* Number of elements in the vector. */
-#endif
-
- void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
-#if __WORDSIZE == 32
- socklen_t msg_controllen; /* Ancillary data buffer length. */
-#else
- size_t msg_controllen; /* Ancillary data buffer length. */
-#endif
-
- int msg_flags; /* Flags on received message. */
- };
-
-/* Structure used for storage of ancillary data object information. */
-struct cmsghdr
- {
- size_t cmsg_len; /* Length of data in cmsg_data plus length
- of cmsghdr structure. */
- int cmsg_level; /* Originating protocol. */
- int cmsg_type; /* Protocol specific type. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
- __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */
-#endif
- };
-
-/* Ancillary data object manipulation macros. */
-#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L
-# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
-#else
-# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
-#endif
-#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
-#define CMSG_FIRSTHDR(mhdr) \
- ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
- ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL)
-#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
- & (size_t) ~(sizeof (size_t) - 1))
-#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
- + CMSG_ALIGN (sizeof (struct cmsghdr)))
-#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
-
-extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
- struct cmsghdr *__cmsg) __THROW;
-libc_hidden_proto(__cmsg_nxthdr)
-#ifdef __USE_EXTERN_INLINES
-# ifndef _EXTERN_INLINE
-# define _EXTERN_INLINE extern __inline
-# endif
-_EXTERN_INLINE struct cmsghdr *
-__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
-{
- if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
- /* The kernel header does this so there may be a reason. */
- return 0;
-
- __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
- + CMSG_ALIGN (__cmsg->cmsg_len));
- if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
- + __mhdr->msg_controllen)
- || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
- > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
- /* No more entries. */
- return 0;
- return __cmsg;
-}
-#endif /* Use `extern inline'. */
-
-/* Socket level message types. This must match the definitions in
- <linux/socket.h>. */
-enum
- {
- SCM_RIGHTS = 0x01 /* Transfer file descriptors. */
-#define SCM_RIGHTS SCM_RIGHTS
-#ifdef __USE_BSD
- , SCM_CREDENTIALS = 0x02 /* Credentials passing. */
-# define SCM_CREDENTIALS SCM_CREDENTIALS
-#endif
- };
-
-/* User visible structure for SCM_CREDENTIALS message */
-
-struct ucred
-{
- pid_t pid; /* PID of sending process. */
- uid_t uid; /* UID of sending process. */
- gid_t gid; /* GID of sending process. */
-};
-
-/* Get socket manipulation related informations from kernel headers. */
-#ifndef __GLIBC__
-#define __GLIBC__ 2
-#include <asm/socket.h>
-#undef __GLIBC__
-#else
-#include <asm/socket.h>
-#endif
-
-
-/* Structure used to manipulate the SO_LINGER option. */
-struct linger
- {
- int l_onoff; /* Nonzero to linger on close. */
- int l_linger; /* Time to linger. */
- };
-
-/* Prefer socketcall over all these for sparc32,
- since it only has socketcall */
-#ifndef __arch64__
- #undef __NR_accept
- #undef __NR_bind
- #undef __NR_connect
- #undef __NR_getpeername
- #undef __NR_getsockname
- #undef __NR_getsockopt
- #undef __NR_listen
- #undef __NR_recv
- #undef __NR_recvfrom
- #undef __NR_recvmsg
- #undef __NR_send
- #undef __NR_sendmsg
- #undef __NR_sendto
- #undef __NR_setsockopt
- #undef __NR_shutdown
- #undef __NR_socket
- #undef __NR_socketpair
-#endif
-
-#endif /* bits/socket.h */
+++ /dev/null
-/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_STATVFS_H
-# error "Never include <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
-#endif
-
-#include <bits/types.h> /* For __fsblkcnt_t and __fsfilcnt_t. */
-
-#if __WORDSIZE == 32
-#define _STATVFSBUF_F_UNUSED
-#endif
-
-struct statvfs
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
- __fsfilcnt_t f_favail;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
-#endif
- unsigned long int f_fsid;
-#ifdef _STATVFSBUF_F_UNUSED
- int __f_unused;
-#endif
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statvfs64
- {
- unsigned long int f_bsize;
- unsigned long int f_frsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsfilcnt64_t f_favail;
- unsigned long int f_fsid;
-#ifdef _STATVFSBUF_F_UNUSED
- int __f_unused;
-#endif
- unsigned long int f_flag;
- unsigned long int f_namemax;
- int __f_spare[6];
- };
-#endif
-
-/* Definitions for the flag in `f_flag'. These definitions should be
- kept in sync which the definitions in <sys/mount.h>. */
-enum
-{
- ST_RDONLY = 1, /* Mount read-only. */
-#define ST_RDONLY ST_RDONLY
- ST_NOSUID = 2, /* Ignore suid and sgid bits. */
-#define ST_NOSUID ST_NOSUID
-#ifdef __USE_GNU
- ST_NODEV = 4, /* Disallow access to device special files. */
-# define ST_NODEV ST_NODEV
- ST_NOEXEC = 8, /* Disallow program execution. */
-# define ST_NOEXEC ST_NOEXEC
- ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
-# define ST_SYNCHRONOUS ST_SYNCHRONOUS
- ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
-# define ST_MANDLOCK ST_MANDLOCK
- ST_WRITE = 128, /* Write on file/directory/symlink. */
-# define ST_WRITE ST_WRITE
- ST_APPEND = 256, /* Append-only file. */
-# define ST_APPEND ST_APPEND
- ST_IMMUTABLE = 512, /* Immutable file. */
-# define ST_IMMUTABLE ST_IMMUTABLE
- ST_NOATIME = 1024, /* Do not update access times. */
-# define ST_NOATIME ST_NOATIME
- ST_NODIRATIME /* Do not update directory access times. */
-# define ST_NODIRATIME ST_NODIRATIME
-#endif /* Use GNU. */
-};
+++ /dev/null
-/* Use new style mmap for v850 */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-
-_syscall6 (__ptr_t, mmap, __ptr_t, addr, size_t, len, int, prot,
- int, flags, int, fd, __off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/* i386-specific implementation of profiling support.
- Copyright (C) 1997, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <sysdep.h>
-
-/* We need a special version of the `mcount' function since for ix86 it
- must not clobber any register. This has several reasons:
- - there is a bug in gcc as of version 2.7.2.2 which prohibits the
- use of profiling together with nested functions
- - the ELF `fixup' function uses GCC's regparm feature
- - some (future) systems might want to pass parameters in registers. */
-
-/* We must not pollute the global namespace. */
-#define mcount_internal __mcount_internal
-
-extern void mcount_internal (u_long frompc, u_long selfpc);
-
-#define _MCOUNT_DECL(frompc, selfpc) \
-void __attribute__ (( regparm (2) )) mcount_internal (u_long frompc, u_long selfpc)
-
-
-/* Define MCOUNT as empty since we have the implementation in another
- file. */
-#define MCOUNT
+++ /dev/null
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _SYS_STATFS_H
-# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
-#endif
-
-#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t*/
-
-struct statfs
- {
- int f_type;
- int f_bsize;
-#ifndef __USE_FILE_OFFSET64
- __fsblkcnt_t f_blocks;
- __fsblkcnt_t f_bfree;
- __fsblkcnt_t f_bavail;
- __fsfilcnt_t f_files;
- __fsfilcnt_t f_ffree;
-#else
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
-#endif
- __fsid_t f_fsid;
- int f_namelen;
- int f_spare[6];
- };
-
-#ifdef __USE_LARGEFILE64
-struct statfs64
- {
- int f_type;
- int f_bsize;
- __fsblkcnt64_t f_blocks;
- __fsblkcnt64_t f_bfree;
- __fsblkcnt64_t f_bavail;
- __fsfilcnt64_t f_files;
- __fsfilcnt64_t f_ffree;
- __fsid_t f_fsid;
- int f_namelen;
- int f_spare[6];
- };
-#endif
+++ /dev/null
-
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/syscall.h>
-
-_syscall6 (void *, mmap, void *, start, size_t, length, int, prot, int, flags,
- int, fd, off_t, offset)
-libc_hidden_def(mmap)
-
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * mmap() for uClibc/x86_64
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-
-
-_syscall6(void *, mmap, void *, start, size_t, length, int, prot,
- int, flags, int, fd, off_t, offset)
-libc_hidden_def(mmap)
+++ /dev/null
-/* Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _SYS_EPOLL_H
-#define _SYS_EPOLL_H 1
-
-#include <stdint.h>
-#include <sys/types.h>
-
-
-enum EPOLL_EVENTS
- {
- EPOLLIN = 0x001,
-#define EPOLLIN EPOLLIN
- EPOLLPRI = 0x002,
-#define EPOLLPRI EPOLLPRI
- EPOLLOUT = 0x004,
-#define EPOLLOUT EPOLLOUT
- EPOLLRDNORM = 0x040,
-#define EPOLLRDNORM EPOLLRDNORM
- EPOLLRDBAND = 0x080,
-#define EPOLLRDBAND EPOLLRDBAND
- EPOLLWRNORM = 0x100,
-#define EPOLLWRNORM EPOLLWRNORM
- EPOLLWRBAND = 0x200,
-#define EPOLLWRBAND EPOLLWRBAND
- EPOLLMSG = 0x400,
-#define EPOLLMSG EPOLLMSG
- EPOLLERR = 0x008,
-#define EPOLLERR EPOLLERR
- EPOLLHUP = 0x010,
-#define EPOLLHUP EPOLLHUP
- EPOLLONESHOT = (1 << 30),
-#define EPOLLONESHOT EPOLLONESHOT
- EPOLLET = (1 << 31)
-#define EPOLLET EPOLLET
- };
-
-
-/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
-#define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */
-#define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */
-#define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */
-
-
-typedef union epoll_data
-{
- void *ptr;
- int fd;
- uint32_t u32;
- uint64_t u64;
-} epoll_data_t;
-
-struct epoll_event
-{
- uint32_t events; /* Epoll events */
- epoll_data_t data; /* User data variable */
-} __attribute__ ((__packed__));
-
-
-__BEGIN_DECLS
-
-/* Creates an epoll instance. Returns an fd for the new instance.
- The "size" parameter is a hint specifying the number of file
- descriptors to be associated with the new instance. The fd
- returned by epoll_create() should be closed with close(). */
-extern int epoll_create (int __size) __THROW;
-
-
-/* Manipulate an epoll instance "epfd". Returns 0 in case of success,
- -1 in case of error ( the "errno" variable will contain the
- specific error code ) The "op" parameter is one of the EPOLL_CTL_*
- constants defined above. The "fd" parameter is the target of the
- operation. The "event" parameter describes which events the caller
- is interested in and any associated user data. */
-extern int epoll_ctl (int __epfd, int __op, int __fd,
- struct epoll_event *__event) __THROW;
-
-
-/* Wait for events on an epoll instance "epfd". Returns the number of
- triggered events returned in "events" buffer. Or -1 in case of
- error with the "errno" variable set to the specific error code. The
- "events" parameter is a buffer that will contain triggered
- events. The "maxevents" is the maximum number of events to be
- returned ( usually size of "events" ). The "timeout" parameter
- specifies the maximum wait time in milliseconds (-1 == infinite).
-
- This function is a cancellation point and therefore not marked with
- __THROW. */
-extern int epoll_wait (int __epfd, struct epoll_event *__events,
- int __maxevents, int __timeout);
-
-__END_DECLS
-
-#endif /* sys/epoll.h */
+++ /dev/null
-/* Copyright (C) 2004 Erik Andersen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * The GNU C Library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the GNU C Library; if not, write to the Free
- * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA.
- */
-
-/* Supply an architecture specific value for PAGE_SIZE and friends. */
-
-#ifndef _UCLIBC_PAGE_H
-#define _UCLIBC_PAGE_H
-
-#include <bits/xtensa-config.h>
-
-/* PAGE_SHIFT determines the page size -- in this case 4096 */
-#define PAGE_SHIFT XCHAL_MMU_MIN_PTE_PAGE_SIZE
-#define PAGE_SIZE (1UL << PAGE_SHIFT)
-#define PAGE_MASK (~(PAGE_SIZE-1))
-
-#endif /* _UCLIBC_PAGE_H */
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for Xtensa uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2007 Tensilica Inc.
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-int posix_fadvise (int fd, off_t offset, off_t len, int advice)
-{
-#ifdef __NR_fadvise64_64
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 31),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 31),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
-}
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for Xtensa uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2007 Tensilica Inc.
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-int posix_fadvise64 (int fd, __off64_t offset, __off64_t len, int advice)
-{
-#ifdef __NR_fadvise64_64
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 32),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 32),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
-}
-
-#endif /* __UCLIBC_HAS_LFS__ */
+++ /dev/null
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-/*
- * Based in part on the files
- * ./sysdeps/unix/sysv/linux/pwrite.c,
- * ./sysdeps/unix/sysv/linux/pread.c,
- * sysdeps/posix/pread.c
- * sysdeps/posix/pwrite.c
- * from GNU libc 2.2.5, but reworked considerably...
- */
-
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <endian.h>
-
-extern __typeof(pread) __libc_pread;
-extern __typeof(pwrite) __libc_pwrite;
-#ifdef __UCLIBC_HAS_LFS__
-extern __typeof(pread64) __libc_pread64;
-extern __typeof(pwrite64) __libc_pwrite64;
-#endif
-
-#include <bits/kernel_types.h>
-
-#ifdef __NR_pread
-
-# define __NR___syscall_pread __NR_pread
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, int, pad, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
- return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-
-#endif /* __NR_pread */
-
-#ifdef __NR_pwrite
-
-# define __NR___syscall_pwrite __NR_pwrite
-/* On Xtensa, 64-bit values are aligned in even/odd register pairs. */
-static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
- size_t, count, int, pad, off_t, offset_hi, off_t, offset_lo)
-
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- return __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset));
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
- return __syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(high, low));
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* __NR_pwrite */
-
-#if ! defined __NR_pread || ! defined __NR_pwrite
-
-static ssize_t __fake_pread_write(int fd, void *buf,
- size_t count, off_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek(fd, 0, SEEK_CUR)) == (off_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. If this fails we
- * have to return this as an error. */
- save_errno = errno;
- if (lseek(fd, old_offset, SEEK_SET) == (off_t) -1)
- {
- if (result == -1)
- __set_errno(save_errno);
- return -1;
- }
- __set_errno(save_errno);
- return(result);
-}
-
-# ifdef __UCLIBC_HAS_LFS__
-
-static ssize_t __fake_pread_write64(int fd, void *buf,
- size_t count, off64_t offset, int do_pwrite)
-{
- int save_errno;
- ssize_t result;
- off64_t old_offset;
-
- /* Since we must not change the file pointer preserve the
- * value so that we can restore it later. */
- if ((old_offset=lseek64(fd, 0, SEEK_CUR)) == (off64_t) -1)
- return -1;
-
- /* Set to wanted position. */
- if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1)
- return -1;
-
- if (do_pwrite == 1) {
- /* Write the data. */
- result = write(fd, buf, count);
- } else {
- /* Read the data. */
- result = read(fd, buf, count);
- }
-
- /* Now we have to restore the position. */
- save_errno = errno;
- if (lseek64(fd, old_offset, SEEK_SET) == (off64_t) -1) {
- if (result == -1)
- __set_errno (save_errno);
- return -1;
- }
- __set_errno (save_errno);
- return result;
-}
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
-
-#ifndef __NR_pread
-ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return __fake_pread_write(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread,pread)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, buf, count, offset, 0);
-}
-weak_alias(__libc_pread64,pread64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pread */
-
-#ifndef __NR_pwrite
-ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- /* we won't actually be modifying the buffer,
- *just cast it to get rid of warnings */
- return __fake_pread_write(fd, (void*)buf, count, offset, 1);
-}
-weak_alias(__libc_pwrite,pwrite)
-
-# ifdef __UCLIBC_HAS_LFS__
-ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
-{
- return __fake_pread_write64(fd, (void*)buf, count, offset, 1);
-}
-weak_alias(__libc_pwrite64,pwrite64)
-# endif /* __UCLIBC_HAS_LFS__ */
-#endif /* ! __NR_pwrite */
+++ /dev/null
-/* `ptrace' debugger support interface. Linux version.
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007
- Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-#ifndef _SYS_PTRACE_H
-#define _SYS_PTRACE_H 1
-
-#include <features.h>
-
-/* Kludge away careless namespace pollution from the kernel. */
-
-#undef PTRACE_GETREGS
-#undef PTRACE_SETREGS
-#undef PTRACE_GETFPREGS
-#undef PTRACE_SETFPREGS
-#undef PTRACE_GETFPREGSIZE
-
-
-__BEGIN_DECLS
-
-/* Type of the REQUEST argument to `ptrace.' */
-enum __ptrace_request
-{
- /* Indicate that the process making this request should be traced.
- All signals received by this process can be intercepted by its
- parent, and its parent can use the other `ptrace' requests. */
- PTRACE_TRACEME = 0,
-#define PT_TRACE_ME PTRACE_TRACEME
-
- /* Return the word in the process's text space at address ADDR. */
- PTRACE_PEEKTEXT = 1,
-#define PT_READ_I PTRACE_PEEKTEXT
-
- /* Return the word in the process's data space at address ADDR. */
- PTRACE_PEEKDATA = 2,
-#define PT_READ_D PTRACE_PEEKDATA
-
- /* Return the word in the process's user area at offset ADDR. */
- PTRACE_PEEKUSER = 3,
-#define PT_READ_U PTRACE_PEEKUSER
-
- /* Write the word DATA into the process's text space at address ADDR. */
- PTRACE_POKETEXT = 4,
-#define PT_WRITE_I PTRACE_POKETEXT
-
- /* Write the word DATA into the process's data space at address ADDR. */
- PTRACE_POKEDATA = 5,
-#define PT_WRITE_D PTRACE_POKEDATA
-
- /* Write the word DATA into the process's user area at offset ADDR. */
- PTRACE_POKEUSER = 6,
-#define PT_WRITE_U PTRACE_POKEUSER
-
- /* Continue the process. */
- PTRACE_CONT = 7,
-#define PT_CONTINUE PTRACE_CONT
-
- /* Kill the process. */
- PTRACE_KILL = 8,
-#define PT_KILL PTRACE_KILL
-
- /* Single step the process.
- This is not supported on all machines. */
- PTRACE_SINGLESTEP = 9,
-#define PT_STEP PTRACE_SINGLESTEP
-
- /* Get all general purpose registers used by a processes.
- This is not supported on all machines. */
- PTRACE_GETREGS = 12,
-#define PT_GETREGS PTRACE_GETREGS
-
- /* Set all general purpose registers used by a processes.
- This is not supported on all machines. */
- PTRACE_SETREGS = 13,
-#define PT_SETREGS PTRACE_SETREGS
-
- /* Get all floating point registers used by a processes.
- This is not supported on all machines. */
- PTRACE_GETFPREGS = 14,
-#define PT_GETFPREGS PTRACE_GETFPREGS
-
- /* Set all floating point registers used by a processes.
- This is not supported on all machines. */
- PTRACE_SETFPREGS = 15,
-#define PT_SETFPREGS PTRACE_SETFPREGS
-
- /* Attach to a process that is already running. */
- PTRACE_ATTACH = 16,
-#define PT_ATTACH PTRACE_ATTACH
-
- /* Detach from a process attached to with PTRACE_ATTACH. */
- PTRACE_DETACH = 17,
-#define PT_DETACH PTRACE_DETACH
-
- /* Get size required for the buffer holding the floating point registers.
- This is not supported on all machines. */
- PTRACE_GETFPREGSIZE = 18,
-#define PT_GETFPREGSIZE PTRACE_GETFPREGSIZE
-
- /* Continue and stop at the next (return from) syscall. */
- PTRACE_SYSCALL = 24
-#define PT_SYSCALL PTRACE_SYSCALL
-};
-
-/* Options set using PTRACE_SETOPTIONS. */
-enum __ptrace_setoptions {
- PTRACE_O_TRACESYSGOOD = 0x00000001,
- PTRACE_O_TRACEFORK = 0x00000002,
- PTRACE_O_TRACEVFORK = 0x00000004,
- PTRACE_O_TRACECLONE = 0x00000008,
- PTRACE_O_TRACEEXEC = 0x00000010,
- PTRACE_O_TRACEVFORKDONE = 0x00000020,
- PTRACE_O_TRACEEXIT = 0x00000040,
- PTRACE_O_MASK = 0x0000007f
-};
-
-/* Wait extended result codes for the above trace options. */
-enum __ptrace_eventcodes {
- PTRACE_EVENT_FORK = 1,
- PTRACE_EVENT_VFORK = 2,
- PTRACE_EVENT_CLONE = 3,
- PTRACE_EVENT_EXEC = 4,
- PTRACE_EVENT_VFORK_DONE = 5,
- PTRACE_EVENT_EXIT = 6
-};
-
-/* Perform process tracing functions. REQUEST is one of the values
- above, and determines the action to be taken.
- For all requests except PTRACE_TRACEME, PID specifies the process to be
- traced.
-
- PID and the other arguments described above for the various requests should
- appear (those that are used for the particular request) as:
- pid_t PID, void *ADDR, int DATA, void *ADDR2
- after REQUEST. */
-extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
-
-__END_DECLS
-
-#endif /* _SYS_PTRACE_H */
+++ /dev/null
-/*
- * This file contains the old semaphore code that we need to
- * preserve for glibc-2.0 backwards compatibility. Port to glibc 2.1
- * done by Cristian Gafton.
- */
-
-/* Linuxthreads - a simple clone()-based implementation of Posix */
-/* threads for Linux. */
-/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
-/* */
-/* This program is free software; you can redistribute it and/or */
-/* modify it under the terms of the GNU Library General Public License */
-/* as published by the Free Software Foundation; either version 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU Library General Public License for more details. */
-
-/* Semaphores a la POSIX 1003.1b */
-
-#include <errno.h>
-#include "pthread.h"
-#include "internals.h"
-#include "spinlock.h"
-#include "restart.h"
-#include "queue.h"
-
-typedef struct {
- long int sem_status;
- int sem_spinlock;
-} old_sem_t;
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
-
-static __inline__ int sem_compare_and_swap(old_sem_t *sem, long oldval, long newval)
-{
- return compare_and_swap(&sem->sem_status, oldval, newval, &sem->sem_spinlock);
-}
-
-/* The state of a semaphore is represented by a long int encoding
- either the semaphore count if >= 0 and no thread is waiting on it,
- or the head of the list of threads waiting for the semaphore.
- To distinguish the two cases, we encode the semaphore count N
- as 2N+1, so that it has the lowest bit set.
-
- A sequence of sem_wait operations on a semaphore initialized to N
- result in the following successive states:
- 2N+1, 2N-1, ..., 3, 1, &first_waiting_thread, &second_waiting_thread, ...
-*/
-
-static void sem_restart_list(pthread_descr waiting);
-
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value);
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value)
-{
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- return -1;
- }
- if (pshared) {
- errno = ENOSYS;
- return -1;
- }
- sem->sem_spinlock = 0;
- sem->sem_status = ((long)value << 1) + 1;
- return 0;
-}
-
-/* Function called by pthread_cancel to remove the thread from
- waiting inside __old_sem_wait. Here we simply unconditionally
- indicate that the thread is to be woken, by returning 1. */
-
-static int old_sem_extricate_func(void *obj attribute_unused, pthread_descr th attribute_unused)
-{
- return 1;
-}
-
-int __old_sem_wait(old_sem_t * sem);
-int __old_sem_wait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
- volatile pthread_descr self = thread_self();
- pthread_descr * th;
- pthread_extricate_if extr;
-
- /* Set up extrication interface */
- extr.pu_object = 0;
- extr.pu_extricate_func = old_sem_extricate_func;
-
- while (1) {
- /* Register extrication interface */
- __pthread_set_own_extricate_if(self, &extr);
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) && (oldstatus != 1))
- newstatus = oldstatus - 2;
- else {
- newstatus = (long) self;
- self->p_nextwaiting = (pthread_descr) oldstatus;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if (newstatus & 1) {
- /* We got the semaphore. */
- __pthread_set_own_extricate_if(self, 0);
- return 0;
- }
- /* Wait for sem_post or cancellation */
- suspend(self);
- __pthread_set_own_extricate_if(self, 0);
-
- /* This is a cancellation point */
- if (self->p_canceled && self->p_cancelstate == PTHREAD_CANCEL_ENABLE) {
- /* Remove ourselves from the waiting list if we're still on it */
- /* First check if we're at the head of the list. */
- do {
- oldstatus = sem->sem_status;
- if (oldstatus != (long) self) break;
- newstatus = (long) self->p_nextwaiting;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- /* Now, check if we're somewhere in the list.
- There's a race condition with sem_post here, but it does not matter:
- the net result is that at the time pthread_exit is called,
- self is no longer reachable from sem->sem_status. */
- if (oldstatus != (long) self && (oldstatus & 1) == 0) {
- for (th = &(((pthread_descr) oldstatus)->p_nextwaiting);
- *th != NULL && *th != (pthread_descr) 1;
- th = &((*th)->p_nextwaiting)) {
- if (*th == self) {
- *th = self->p_nextwaiting;
- break;
- }
- }
- }
- __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
- }
- }
-}
-
-int __old_sem_trywait(old_sem_t * sem);
-int __old_sem_trywait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0 || (oldstatus == 1)) {
- errno = EAGAIN;
- return -1;
- }
- newstatus = oldstatus - 2;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- return 0;
-}
-
-int __old_sem_post(old_sem_t * sem);
-int __old_sem_post(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0)
- newstatus = 3;
- else {
- if (oldstatus >= SEM_VALUE_MAX) {
- /* Overflow */
- errno = ERANGE;
- return -1;
- }
- newstatus = oldstatus + 2;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if ((oldstatus & 1) == 0)
- sem_restart_list((pthread_descr) oldstatus);
- return 0;
-}
-
-int __old_sem_getvalue(old_sem_t * sem, int * sval);
-int __old_sem_getvalue(old_sem_t * sem, int * sval)
-{
- long status = sem->sem_status;
- if (status & 1)
- *sval = (int)((unsigned long) status >> 1);
- else
- *sval = 0;
- return 0;
-}
-
-int __old_sem_destroy(old_sem_t * sem);
-int __old_sem_destroy(old_sem_t * sem)
-{
- if ((sem->sem_status & 1) == 0) {
- errno = EBUSY;
- return -1;
- }
- return 0;
-}
-
-/* Auxiliary function for restarting all threads on a waiting list,
- in priority order. */
-
-static void sem_restart_list(pthread_descr waiting)
-{
- pthread_descr th, towake, *p;
-
- /* Sort list of waiting threads by decreasing priority (insertion sort) */
- towake = NULL;
- while (waiting != (pthread_descr) 1) {
- th = waiting;
- waiting = waiting->p_nextwaiting;
- p = &towake;
- while (*p != NULL && th->p_priority < (*p)->p_priority)
- p = &((*p)->p_nextwaiting);
- th->p_nextwaiting = *p;
- *p = th;
- }
- /* Wake up threads in priority order */
- while (towake != NULL) {
- th = towake;
- towake = towake->p_nextwaiting;
- th->p_nextwaiting = NULL;
- restart(th);
- }
-}
-
-#if defined __PIC__ && defined DO_VERSIONING
-symbol_version (__old_sem_init, sem_init, GLIBC_2.0);
-symbol_version (__old_sem_wait, sem_wait, GLIBC_2.0);
-symbol_version (__old_sem_trywait, sem_trywait, GLIBC_2.0);
-symbol_version (__old_sem_post, sem_post, GLIBC_2.0);
-symbol_version (__old_sem_getvalue, sem_getvalue, GLIBC_2.0);
-symbol_version (__old_sem_destroy, sem_destroy, GLIBC_2.0);
-#endif
-
+++ /dev/null
-.cvsignore
-*.os
-Makefile.in
+++ /dev/null
-/* Generic asm macros used on many machines.
- Copyright (C) 1991,92,93,96,98,2002,2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef C_LABEL
-
-/* Define a macro we can use to construct the asm name for a C symbol. */
-#ifdef NO_UNDERSCORES
-#ifdef __STDC__
-#define C_LABEL(name) name##:
-#else
-#define C_LABEL(name) name/**/:
-#endif
-#else
-#ifdef __STDC__
-#define C_LABEL(name) _##name##:
-#else
-#define C_LABEL(name) _/**/name/**/:
-#endif
-#endif
-
-#endif
-
-#ifdef __ASSEMBLER__
-/* Mark the end of function named SYM. This is used on some platforms
- to generate correct debugging information. */
-#ifndef END
-#define END(sym)
-#endif
-
-#ifndef JUMPTARGET
-#define JUMPTARGET(sym) sym
-#endif
-
-/* Makros to generate eh_frame unwind information. */
-# ifdef HAVE_ASM_CFI_DIRECTIVES
-# define cfi_startproc .cfi_startproc
-# define cfi_endproc .cfi_endproc
-# define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off
-# define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
-# define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off
-# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
-# define cfi_offset(reg, off) .cfi_offset reg, off
-# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
-# define cfi_register(r1, r2) .cfi_register r1, r2
-# define cfi_return_column(reg) .cfi_return_column reg
-# define cfi_restore(reg) .cfi_restore reg
-# define cfi_same_value(reg) .cfi_same_value reg
-# define cfi_undefined(reg) .cfi_undefined reg
-# define cfi_remember_state .cfi_remember_state
-# define cfi_restore_state .cfi_restore_state
-# define cfi_window_save .cfi_window_save
-# else
-# define cfi_startproc
-# define cfi_endproc
-# define cfi_def_cfa(reg, off)
-# define cfi_def_cfa_register(reg)
-# define cfi_def_cfa_offset(off)
-# define cfi_adjust_cfa_offset(off)
-# define cfi_offset(reg, off)
-# define cfi_rel_offset(reg, off)
-# define cfi_register(r1, r2)
-# define cfi_return_column(reg)
-# define cfi_restore(reg)
-# define cfi_same_value(reg)
-# define cfi_undefined(reg)
-# define cfi_remember_state
-# define cfi_restore_state
-# define cfi_window_save
-# endif
-
-#else /* ! ASSEMBLER */
-# ifdef HAVE_ASM_CFI_DIRECTIVES
-# define CFI_STRINGIFY(Name) CFI_STRINGIFY2 (Name)
-# define CFI_STRINGIFY2(Name) #Name
-# define CFI_STARTPROC ".cfi_startproc"
-# define CFI_ENDPROC ".cfi_endproc"
-# define CFI_DEF_CFA(reg, off) \
- ".cfi_def_cfa " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
-# define CFI_DEF_CFA_REGISTER(reg) \
- ".cfi_def_cfa_register " CFI_STRINGIFY(reg)
-# define CFI_DEF_CFA_OFFSET(off) \
- ".cfi_def_cfa_offset " CFI_STRINGIFY(off)
-# define CFI_ADJUST_CFA_OFFSET(off) \
- ".cfi_adjust_cfa_offset " CFI_STRINGIFY(off)
-# define CFI_OFFSET(reg, off) \
- ".cfi_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
-# define CFI_REL_OFFSET(reg, off) \
- ".cfi_rel_offset " CFI_STRINGIFY(reg) "," CFI_STRINGIFY(off)
-# define CFI_REGISTER(r1, r2) \
- ".cfi_register " CFI_STRINGIFY(r1) "," CFI_STRINGIFY(r2)
-# define CFI_RETURN_COLUMN(reg) \
- ".cfi_return_column " CFI_STRINGIFY(reg)
-# define CFI_RESTORE(reg) \
- ".cfi_restore " CFI_STRINGIFY(reg)
-# define CFI_UNDEFINED(reg) \
- ".cfi_undefined " CFI_STRINGIFY(reg)
-# define CFI_REMEMBER_STATE \
- ".cfi_remember_state"
-# define CFI_RESTORE_STATE \
- ".cfi_restore_state"
-# define CFI_WINDOW_SAVE \
- ".cfi_window_save"
-# else
-# define CFI_STARTPROC
-# define CFI_ENDPROC
-# define CFI_DEF_CFA(reg, off)
-# define CFI_DEF_CFA_REGISTER(reg)
-# define CFI_DEF_CFA_OFFSET(off)
-# define CFI_ADJUST_CFA_OFFSET(off)
-# define CFI_OFFSET(reg, off)
-# define CFI_REL_OFFSET(reg, off)
-# define CFI_REGISTER(r1, r2)
-# define CFI_RETURN_COLUMN(reg)
-# define CFI_RESTORE(reg)
-# define CFI_UNDEFINED(reg)
-# define CFI_REMEMBER_STATE
-# define CFI_RESTORE_STATE
-# define CFI_WINDOW_SAVE
-# endif
-
-#endif /* __ASSEMBLER__ */
+++ /dev/null
-.cvsignore
-*.os
+++ /dev/null
-.cvsignore
-*.os
+++ /dev/null
-.cvsignore
-.svn
-*.os
-Makefile
-Makefile.in
+++ /dev/null
-#include <../../../../libc/sysdeps/linux/arm/aeabi_unwind_cpp_pr1.c>
+++ /dev/null
-/* Exception handling and frame unwind runtime interface routines.
- Copyright (C) 2001, 2003 Free Software Foundation, Inc.
-
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-/* This is derived from the C++ ABI for IA-64. Where we diverge
- for cross-architecture compatibility are noted with "@@@". */
-
-#ifndef _UNWIND_H
-#define _UNWIND_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Level 1: Base ABI */
-
-/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
- inefficient for 32-bit and smaller machines. */
-typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
-typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
-#if defined(__ia64__) && defined(__hpux__)
-typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
-#else
-typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
-#endif
-typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
-
-/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
- consumer of an exception. We'll go along with this for now even on
- 32-bit machines. We'll need to provide some other option for
- 16-bit machines and for machines with > 8 bits per byte. */
-typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
-
-/* The unwind interface uses reason codes in several contexts to
- identify the reasons for failures or other actions. */
-typedef enum
-{
- _URC_NO_REASON = 0,
- _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
- _URC_FATAL_PHASE2_ERROR = 2,
- _URC_FATAL_PHASE1_ERROR = 3,
- _URC_NORMAL_STOP = 4,
- _URC_END_OF_STACK = 5,
- _URC_HANDLER_FOUND = 6,
- _URC_INSTALL_CONTEXT = 7,
- _URC_CONTINUE_UNWIND = 8
-} _Unwind_Reason_Code;
-
-
-/* The unwind interface uses a pointer to an exception header object
- as its representation of an exception being thrown. In general, the
- full representation of an exception object is language- and
- implementation-specific, but it will be prefixed by a header
- understood by the unwind interface. */
-
-struct _Unwind_Exception;
-
-typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
- struct _Unwind_Exception *);
-
-struct _Unwind_Exception
-{
- _Unwind_Exception_Class exception_class;
- _Unwind_Exception_Cleanup_Fn exception_cleanup;
- _Unwind_Word private_1;
- _Unwind_Word private_2;
-
- /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
- Taking that literally does not make much sense generically. Instead we
- provide the maximum alignment required by any type for the machine. */
-} __attribute__((__aligned__));
-
-
-/* The ACTIONS argument to the personality routine is a bitwise OR of one
- or more of the following constants. */
-typedef int _Unwind_Action;
-
-#define _UA_SEARCH_PHASE 1
-#define _UA_CLEANUP_PHASE 2
-#define _UA_HANDLER_FRAME 4
-#define _UA_FORCE_UNWIND 8
-#define _UA_END_OF_STACK 16
-
-/* This is an opaque type used to refer to a system-specific data
- structure used by the system unwinder. This context is created and
- destroyed by the system, and passed to the personality routine
- during unwinding. */
-struct _Unwind_Context;
-
-/* Raise an exception, passing along the given exception object. */
-extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
-
-/* Raise an exception for forced unwinding. */
-
-typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
- (int, _Unwind_Action, _Unwind_Exception_Class,
- struct _Unwind_Exception *, struct _Unwind_Context *, void *);
-
-extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
- _Unwind_Stop_Fn,
- void *);
-
-/* Helper to invoke the exception_cleanup routine. */
-extern void _Unwind_DeleteException (struct _Unwind_Exception *);
-
-/* Resume propagation of an existing exception. This is used after
- e.g. executing cleanup code, and not to implement rethrowing. */
-extern void _Unwind_Resume (struct _Unwind_Exception *);
-
-/* @@@ Use unwind data to perform a stack backtrace. The trace callback
- is called for every stack frame in the call chain, but no cleanup
- actions are performed. */
-typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
- (struct _Unwind_Context *, void *);
-
-extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
-
-/* These functions are used for communicating information about the unwind
- context (i.e. the unwind descriptors and the user register state) between
- the unwind library and the personality routine and landing pad. Only
- selected registers maybe manipulated. */
-
-extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
-extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
-
-extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
-extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
-
-/* @@@ Retrieve the CFA of the given context. */
-extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
-
-extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
-
-extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
-
-
-/* The personality routine is the function in the C++ (or other language)
- runtime library which serves as an interface between the system unwind
- library and language-specific exception handling semantics. It is
- specific to the code fragment described by an unwind info block, and
- it is always referenced via the pointer in the unwind info block, and
- hence it has no ABI-specified name.
-
- Note that this implies that two different C++ implementations can
- use different names, and have different contents in the language
- specific data area. Moreover, that the language specific data
- area contains no version info because name of the function invoked
- provides more effective versioning by detecting at link time the
- lack of code to handle the different data format. */
-
-typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
- (int, _Unwind_Action, _Unwind_Exception_Class,
- struct _Unwind_Exception *, struct _Unwind_Context *);
-
-/* @@@ The following alternate entry points are for setjmp/longjmp
- based unwinding. */
-
-struct SjLj_Function_Context;
-extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
-extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
-
-extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
- (struct _Unwind_Exception *);
-extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
- (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
-extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
-
-/* @@@ The following provide access to the base addresses for text
- and data-relative addressing in the LDSA. In order to stay link
- compatible with the standard ABI for IA-64, we inline these. */
-
-#ifdef __ia64__
-#include <stdlib.h>
-
-static inline _Unwind_Ptr
-_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
-{
- /* The GP is stored in R1. */
- return _Unwind_GetGR (_C, 1);
-}
-
-static inline _Unwind_Ptr
-_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
-{
- abort ();
- return 0;
-}
-
-/* @@@ Retrieve the Backing Store Pointer of the given context. */
-extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
-#else
-extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
-extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
-#endif
-
-/* @@@ Given an address, return the entry point of the function that
- contains it. */
-extern void * _Unwind_FindEnclosingFunction (void *pc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* unwind.h */
+++ /dev/null
-/^[ ]*\.endp/ { need_endp = 1 }
-/^[ ]*\.end/ { need_end = 1 }
-/^[ ]*\.align/ { if($2 > max) max = $2; }
-
-END {
- if(need_endp)
- {
- print "#define END_INIT .endp _init";
- print "#define END_FINI .endp _fini";
- } else if(need_end)
- {
- print "#define END_INIT .end _init";
- print "#define END_FINI .end _fini";
- }
- else
- {
- print "#define END_INIT";
- print "#define END_FINI";
- }
- if(max)
- print "#define ALIGN .align", max;
- else
- print "#define ALIGN";
-}
+++ /dev/null
-/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef LIBC_SIGACTION
-
-#include <pthreadP.h>
-
-/* We use the libc implementation but we tell it to not allow
- SIGCANCEL or SIGTIMER to be handled. */
-#define LIBC_SIGACTION 1
-#include <sigaction.c>
-
-extern __typeof(sigaction) __sigaction;
-int
-__sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
-{
- if (__builtin_expect (sig == SIGCANCEL || sig == SIGSETXID, 0))
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- return __libc_sigaction (sig, act, oact);
-}
-libc_hidden_proto(sigaction)
-weak_alias (__sigaction, sigaction)
-libc_hidden_weak(sigaction)
-
-#else
-
-# include_next <sigaction.c>
-
-#endif /* LIBC_SIGACTION */
+++ /dev/null
-/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <stdint.h>
-#include <sysdep.h>
-
-
-typedef int8_t atomic8_t;
-typedef uint8_t uatomic8_t;
-typedef int_fast8_t atomic_fast8_t;
-typedef uint_fast8_t uatomic_fast8_t;
-
-typedef int32_t atomic32_t;
-typedef uint32_t uatomic32_t;
-typedef int_fast32_t atomic_fast32_t;
-typedef uint_fast32_t uatomic_fast32_t;
-
-typedef intptr_t atomicptr_t;
-typedef uintptr_t uatomicptr_t;
-typedef intmax_t atomic_max_t;
-typedef uintmax_t uatomic_max_t;
-
-void __arm_link_error (void);
-
-#ifdef __thumb2__
-#define atomic_full_barrier() \
- __asm__ __volatile__ \
- ("movw\tip, #0x0fa0\n\t" \
- "movt\tip, #0xffff\n\t" \
- "blx\tip" \
- : : : "ip", "lr", "cc", "memory");
-#else
-#define atomic_full_barrier() \
- __asm__ __volatile__ \
- ("mov\tip, #0xffff0fff\n\t" \
- "mov\tlr, pc\n\t" \
- "add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" \
- : : : "ip", "lr", "cc", "memory");
-#endif
-
-/* Atomic compare and exchange. This sequence relies on the kernel to
- provide a compare and exchange operation which is atomic on the
- current architecture, either via cleverness on pre-ARMv6 or via
- ldrex / strex on ARMv6. */
-
-#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
- ({ __arm_link_error (); oldval; })
-
-#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
- ({ __arm_link_error (); oldval; })
-
-/* It doesn't matter what register is used for a_oldval2, but we must
- specify one to work around GCC PR rtl-optimization/21223. Otherwise
- it may cause a_oldval or a_tmp to be moved to a different register. */
-
-#ifdef __thumb2__
-/* Thumb-2 has ldrex/strex. However it does not have barrier instructions,
- so we still need to use the kernel helper. */
-#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
- register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
- register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
- register __typeof (oldval) a_tmp __asm__ ("r3"); \
- register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
- __asm__ __volatile__ \
- ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \
- "cmp\t%[tmp], %[old2]\n\t" \
- "bne\t1f\n\t" \
- "mov\t%[old], %[old2]\n\t" \
- "movw\t%[tmp], #0x0fc0\n\t" \
- "movt\t%[tmp], #0xffff\n\t" \
- "blx\t%[tmp]\n\t" \
- "bcc\t0b\n\t" \
- "mov\t%[tmp], %[old2]\n\t" \
- "1:" \
- : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \
- : [new] "r" (a_newval), [ptr] "r" (a_ptr), \
- [old2] "r" (a_oldval2) \
- : "ip", "lr", "cc", "memory"); \
- a_tmp; })
-#else
-#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
- ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \
- register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \
- register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \
- register __typeof (oldval) a_tmp __asm__ ("r3"); \
- register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \
- __asm__ __volatile__ \
- ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \
- "cmp\t%[tmp], %[old2]\n\t" \
- "bne\t1f\n\t" \
- "mov\t%[old], %[old2]\n\t" \
- "mov\t%[tmp], #0xffff0fff\n\t" \
- "mov\tlr, pc\n\t" \
- "add\tpc, %[tmp], #(0xffff0fc0 - 0xffff0fff)\n\t" \
- "bcc\t0b\n\t" \
- "mov\t%[tmp], %[old2]\n\t" \
- "1:" \
- : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \
- : [new] "r" (a_newval), [ptr] "r" (a_ptr), \
- [old2] "r" (a_oldval2) \
- : "ip", "lr", "cc", "memory"); \
- a_tmp; })
-#endif
-
-#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
- ({ __arm_link_error (); oldval; })
+++ /dev/null
-#include <aeabi_unwind_cpp_pr1.c>
+++ /dev/null
-/* Header file for the ARM EABI unwinder
- Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
- Contributed by Paul Brook
-
- This file is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
-
- In addition to the permissions in the GNU General Public License, the
- Free Software Foundation gives you unlimited permission to link the
- compiled version of this file into combinations with other programs,
- and to distribute those combinations without any restriction coming
- from the use of this file. (The General Public License restrictions
- do apply in other respects; for example, they cover modification of
- the file, and distribution when not linked into a combine
- executable.)
-
- This file is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- the Free Software Foundation, 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* Language-independent unwinder header public defines. This contains both
- ABI defined objects, and GNU support routines. */
-
-#ifndef UNWIND_ARM_H
-#define UNWIND_ARM_H
-
-#define __ARM_EABI_UNWINDER__ 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
- typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
- typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
- typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
- typedef _Unwind_Word _uw;
- typedef unsigned _uw64 __attribute__((mode(__DI__)));
- typedef unsigned _uw16 __attribute__((mode(__HI__)));
- typedef unsigned _uw8 __attribute__((mode(__QI__)));
-
- typedef enum
- {
- _URC_OK = 0, /* operation completed successfully */
- _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
- _URC_END_OF_STACK = 5,
- _URC_HANDLER_FOUND = 6,
- _URC_INSTALL_CONTEXT = 7,
- _URC_CONTINUE_UNWIND = 8,
- _URC_FAILURE = 9 /* unspecified failure of some kind */
- }
- _Unwind_Reason_Code;
-
- typedef enum
- {
- _US_VIRTUAL_UNWIND_FRAME = 0,
- _US_UNWIND_FRAME_STARTING = 1,
- _US_UNWIND_FRAME_RESUME = 2,
- _US_ACTION_MASK = 3,
- _US_FORCE_UNWIND = 8,
- _US_END_OF_STACK = 16
- }
- _Unwind_State;
-
- /* Provided only for for compatibility with existing code. */
- typedef int _Unwind_Action;
-#define _UA_SEARCH_PHASE 1
-#define _UA_CLEANUP_PHASE 2
-#define _UA_HANDLER_FRAME 4
-#define _UA_FORCE_UNWIND 8
-#define _UA_END_OF_STACK 16
-#define _URC_NO_REASON _URC_OK
-
- typedef struct _Unwind_Control_Block _Unwind_Control_Block;
- typedef struct _Unwind_Context _Unwind_Context;
- typedef _uw _Unwind_EHT_Header;
-
-
- /* UCB: */
-
- struct _Unwind_Control_Block
- {
-#ifdef _LIBC
- /* For the benefit of code which assumes this is a scalar. All
- glibc ever does is clear it. */
- _uw64 exception_class;
-#else
- char exception_class[8];
-#endif
- void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
- /* Unwinder cache, private fields for the unwinder's use */
- struct
- {
- _uw reserved1; /* Forced unwind stop fn, 0 if not forced */
- _uw reserved2; /* Personality routine address */
- _uw reserved3; /* Saved callsite address */
- _uw reserved4; /* Forced unwind stop arg */
- _uw reserved5;
- }
- unwinder_cache;
- /* Propagation barrier cache (valid after phase 1): */
- struct
- {
- _uw sp;
- _uw bitpattern[5];
- }
- barrier_cache;
- /* Cleanup cache (preserved over cleanup): */
- struct
- {
- _uw bitpattern[4];
- }
- cleanup_cache;
- /* Pr cache (for pr's benefit): */
- struct
- {
- _uw fnstart; /* function start address */
- _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
- _uw additional; /* additional data */
- _uw reserved1;
- }
- pr_cache;
- long long int :0; /* Force alignment to 8-byte boundary */
- };
-
- /* Virtual Register Set*/
-
- typedef enum
- {
- _UVRSC_CORE = 0, /* integer register */
- _UVRSC_VFP = 1, /* vfp */
- _UVRSC_FPA = 2, /* fpa */
- _UVRSC_WMMXD = 3, /* Intel WMMX data register */
- _UVRSC_WMMXC = 4 /* Intel WMMX control register */
- }
- _Unwind_VRS_RegClass;
-
- typedef enum
- {
- _UVRSD_UINT32 = 0,
- _UVRSD_VFPX = 1,
- _UVRSD_FPAX = 2,
- _UVRSD_UINT64 = 3,
- _UVRSD_FLOAT = 4,
- _UVRSD_DOUBLE = 5
- }
- _Unwind_VRS_DataRepresentation;
-
- typedef enum
- {
- _UVRSR_OK = 0,
- _UVRSR_NOT_IMPLEMENTED = 1,
- _UVRSR_FAILED = 2
- }
- _Unwind_VRS_Result;
-
- /* Frame unwinding state. */
- typedef struct
- {
- /* The current word (bytes packed msb first). */
- _uw data;
- /* Pointer to the next word of data. */
- _uw *next;
- /* The number of bytes left in this word. */
- _uw8 bytes_left;
- /* The number of words pointed to by ptr. */
- _uw8 words_left;
- }
- __gnu_unwind_state;
-
- typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
- _Unwind_Control_Block *, _Unwind_Context *);
-
- _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
- _uw, _Unwind_VRS_DataRepresentation,
- void *);
-
- _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
- _uw, _Unwind_VRS_DataRepresentation,
- void *);
-
- _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
- _uw, _Unwind_VRS_DataRepresentation);
-
-
- /* Support functions for the PR. */
-#define _Unwind_Exception _Unwind_Control_Block
- typedef char _Unwind_Exception_Class[8];
-
- void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
- _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
-
- /* These two should never be used. */
- _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
- _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
-
- /* Interface functions: */
- _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
- void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
- _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
-
- typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
- (int, _Unwind_Action, _Unwind_Exception_Class,
- _Unwind_Control_Block *, struct _Unwind_Context *, void *);
- _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
- _Unwind_Stop_Fn, void *);
- _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
- void _Unwind_Complete(_Unwind_Control_Block *ucbp);
- void _Unwind_DeleteException (_Unwind_Exception *);
-
- _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
- _Unwind_Context *);
- _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
- __gnu_unwind_state *);
-
- /* Decode an R_ARM_TARGET2 relocation. */
- static inline _Unwind_Word
- _Unwind_decode_target2 (_Unwind_Word ptr)
- {
- _Unwind_Word tmp;
-
- tmp = *(_Unwind_Word *) ptr;
- /* Zero values are always NULL. */
- if (!tmp)
- return 0;
-
-#if defined(linux) || defined(__NetBSD__)
- /* Pc-relative indirect. */
- tmp += ptr;
- tmp = *(_Unwind_Word *) tmp;
-#elif defined(__symbian__)
- /* Absolute pointer. Nothing more to do. */
-#else
- /* Pc-relative pointer. */
- tmp += ptr;
-#endif
- return tmp;
- }
-
- static inline _Unwind_Word
- _Unwind_GetGR (_Unwind_Context *context, int regno)
- {
- _uw val;
- _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
- return val;
- }
-
- /* Return the address of the instruction, not the actual IP value. */
-#define _Unwind_GetIP(context) \
- (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
-
- static inline void
- _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
- {
- _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
- }
-
- /* The dwarf unwinder doesn't understand arm/thumb state. We assume the
- landing pad uses the same instruction set as the call site. */
-#define _Unwind_SetIP(context, val) \
- _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
-
-typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
- (struct _Unwind_Context *, void *);
-
-extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* defined UNWIND_ARM_H */
+++ /dev/null
-# Makefile for uClibc (sh/libubacktrace)
-#
-# Copyright (C) 2010 STMicroelectronics Ltd
-# Author: Carmelo Amoroso <carmelo.amoroso@st.com>
-
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-
-libubacktrace_ARCH_SRC-y := backtrace.c
-
-# -fexections is required for backtrace to work using dwarf2
-CFLAGS-backtrace.c := -fexceptions
+++ /dev/null
-/*
- * Perform stack unwinding by using the _Unwind_Backtrace.
- *
- * User application that wants to use backtrace needs to be
- * compiled with -fexceptions option and -rdynamic to get full
- * symbols printed.
- *
- * Copyright (C) 2009, 2010 STMicroelectronics Ltd.
- *
- * Author(s): Giuseppe Cavallaro <peppe.cavallaro@st.com>
- * - Initial implementation for glibc
- *
- * Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
- * - Reworked for uClibc
- * - use dlsym/dlopen from libdl
- * - rewrite initialisation to not use libc_once
- * - make it available in static link too
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- *
- */
-
-#include <execinfo.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <unwind.h>
-#include <assert.h>
-#include <stdio.h>
-
-struct trace_arg
-{
- void **array;
- int cnt, size;
-};
-
-static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
-static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
-
-static void backtrace_init (void)
-{
- void *handle = dlopen ("libgcc_s.so.1", RTLD_LAZY);
-
- if (handle == NULL
- || ((unwind_backtrace = dlsym (handle, "_Unwind_Backtrace")) == NULL)
- || ((unwind_getip = dlsym (handle, "_Unwind_GetIP")) == NULL)) {
- printf("libgcc_s.so.1 must be installed for backtrace to work\n");
- abort();
- }
-}
-
-static _Unwind_Reason_Code
-backtrace_helper (struct _Unwind_Context *ctx, void *a)
-{
- struct trace_arg *arg = a;
-
- assert (unwind_getip != NULL);
-
- /* We are first called with address in the __backtrace function. Skip it. */
- if (arg->cnt != -1)
- arg->array[arg->cnt] = (void *) unwind_getip (ctx);
- if (++arg->cnt == arg->size)
- return _URC_END_OF_STACK;
- return _URC_NO_REASON;
-}
-
-/*
- * Perform stack unwinding by using the _Unwind_Backtrace.
- *
- * User application that wants to use backtrace needs to be
- * compiled with -fexceptions option and -rdynamic to get full
- * symbols printed.
- */
-int backtrace (void **array, int size)
-{
- struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
-
- if (unwind_backtrace == NULL)
- backtrace_init();
-
- if (size >= 1)
- unwind_backtrace (backtrace_helper, &arg);
-
- return arg.cnt != -1 ? arg.cnt : 0;
-}
+++ /dev/null
-# Begin of automatic generation
-
-# asin
-Test "asin (-0.5) == -pi/6":
-float: 2
-ifloat: 2
-Test "asin (0.5) == pi/6":
-float: 2
-ifloat: 2
-Test "asin (0.7) == 0.7753974966107530637":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-# atan2
-Test "atan2 (0.7, -1.0) == 2.530866689200584621918884506789267":
-float: 3
-ifloat: 3
-Test "atan2 (-0.7, -1.0) == -2.530866689200584621918884506789267":
-float: 3
-ifloat: 3
-Test "atan2 (1.4, -0.93) == 2.1571487668237843754887415992772736":
-float: 4
-ifloat: 4
-
-# atanh
-Test "atanh (0.7) == 0.8673005276940531944":
-double: 1
-idouble: 1
-
-# cabs
-Test "cabs (-0.7 + 12.4 i) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "cabs (-0.7 - 12.4 i) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "cabs (-12.4 + 0.7 i) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "cabs (-12.4 - 0.7 i) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "cabs (0.7 + 1.2 i) == 1.3892443989449804508432547041028554":
-double: 1
-idouble: 1
-Test "cabs (0.7 + 12.4 i) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-
-# cacos
-Test "Real part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Imaginary part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
-float: 1
-ifloat: 1
-
-# cacosh
-Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
-double: 1
-float: 7
-idouble: 1
-ifloat: 7
-Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
-double: 1
-float: 3
-idouble: 1
-ifloat: 3
-Test "Real part of: cacosh (0.7 + 1.2 i) == 1.0927647857577371459105272080819308 + 1.1351827477151551088992008271819053 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# casin
-Test "Real part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
-double: 3
-float: 2
-idouble: 3
-ifloat: 2
-Test "Imaginary part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
-float: 1
-ifloat: 1
-
-# casinh
-Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
-double: 5
-float: 1
-idouble: 5
-ifloat: 1
-Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
-double: 3
-float: 6
-idouble: 3
-ifloat: 6
-Test "Real part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
-double: 1
-idouble: 1
-Test "Imaginary part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
-float: 1
-ifloat: 1
-
-# catan
-Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
-float: 3
-ifloat: 3
-Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Real part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
-float: 4
-ifloat: 4
-Test "Imaginary part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
-double: 1
-idouble: 1
-
-# catanh
-Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
-double: 4
-idouble: 4
-Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
-float: 4
-ifloat: 4
-Test "Real part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
-double: 1
-float: 6
-idouble: 1
-ifloat: 6
-
-# cbrt
-Test "cbrt (-27.0) == -3.0":
-double: 1
-idouble: 1
-Test "cbrt (0.970299) == 0.99":
-double: 1
-idouble: 1
-
-# ccos
-Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
-float: 1
-ifloat: 1
-Test "Real part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
-double: 1
-idouble: 1
-Test "Imaginary part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
-double: 1
-idouble: 1
-
-# ccosh
-Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
-float: 1
-ifloat: 1
-Test "Real part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Imaginary part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
-double: 1
-idouble: 1
-
-# cexp
-Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
-float: 1
-ifloat: 1
-Test "Real part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Imaginary part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
-float: 1
-ifloat: 1
-
-# clog
-Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
-double: 1
-float: 3
-idouble: 1
-ifloat: 3
-
-# clog10
-Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
-double: 1
-float: 5
-idouble: 1
-ifloat: 5
-Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Real part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
-double: 1
-idouble: 1
-Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
-float: 1
-ifloat: 1
-
-# cos
-Test "cos (0.7) == 0.7648421872844884262":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "cos (M_PI_6l * 2.0) == 0.5":
-double: 1
-float: 0.5
-idouble: 1
-ifloat: 0.5
-Test "cos (M_PI_6l * 4.0) == -0.5":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "cos (pi/2) == 0":
-double: 0.2758
-float: 0.3667
-idouble: 0.2758
-ifloat: 0.3667
-
-# cpow
-Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
-double: 1
-float: 4
-idouble: 1
-ifloat: 4
-Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
-float: 2
-ifloat: 2
-Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
-double: 1.1031
-float: 1.5
-idouble: 1.1031
-ifloat: 1.5
-
-# csin
-Test "Imaginary part of: csin (0.7 + 1.2 i) == 1.1664563419657581376 + 1.1544997246948547371 i":
-float: 1
-ifloat: 1
-
-# csinh
-Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
-double: 1
-idouble: 1
-Test "Real part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
-float: 1
-ifloat: 1
-
-# csqrt
-Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
-float: 1
-ifloat: 1
-Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
-float: 1
-ifloat: 1
-Test "Real part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "Imaginary part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
-float: 1
-ifloat: 1
-
-# ctan
-Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
-double: 1
-idouble: 1
-Test "Real part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
-float: 1
-ifloat: 1
-Test "Imaginary part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# ctanh
-Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
-float: 1
-ifloat: 1
-Test "Real part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "Imaginary part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-# erfc
-Test "erfc (0.7) == 0.32219880616258152702":
-double: 1
-idouble: 1
-Test "erfc (1.2) == 0.089686021770364619762":
-double: 2
-float: 2
-idouble: 2
-ifloat: 2
-Test "erfc (2.0) == 0.0046777349810472658379":
-double: 1
-idouble: 1
-Test "erfc (4.1) == 0.67000276540848983727e-8":
-double: 24
-float: 12
-idouble: 24
-ifloat: 12
-
-# exp10
-Test "exp10 (-1) == 0.1":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "exp10 (0.7) == 5.0118723362727228500":
-float: 1
-ifloat: 1
-Test "exp10 (3) == 1000":
-double: 6
-float: 2
-idouble: 6
-ifloat: 2
-
-# expm1
-Test "expm1 (1) == M_El - 1.0":
-float: 1
-ifloat: 1
-
-# fmod
-Test "fmod (-6.5, -2.3) == -1.9":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "fmod (-6.5, 2.3) == -1.9":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "fmod (6.5, -2.3) == 1.9":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "fmod (6.5, 2.3) == 1.9":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-# hypot
-Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (0.7, 1.2) == 1.3892443989449804508432547041028554":
-double: 1
-idouble: 1
-Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
-float: 1
-ifloat: 1
-
-# j0
-Test "j0 (10.0) == -0.24593576445134833520":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "j0 (2.0) == 0.22389077914123566805":
-float: 2
-ifloat: 2
-Test "j0 (8.0) == 0.17165080713755390609":
-float: 1
-ifloat: 1
-
-# j1
-Test "j1 (10.0) == 0.043472746168861436670":
-float: 2
-ifloat: 2
-Test "j1 (2.0) == 0.57672480775687338720":
-double: 1
-idouble: 1
-Test "j1 (8.0) == 0.23463634685391462438":
-double: 1
-idouble: 1
-
-# jn
-Test "jn (0, 10.0) == -0.24593576445134833520":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "jn (0, 2.0) == 0.22389077914123566805":
-float: 2
-ifloat: 2
-Test "jn (0, 8.0) == 0.17165080713755390609":
-float: 1
-ifloat: 1
-Test "jn (1, 10.0) == 0.043472746168861436670":
-float: 2
-ifloat: 2
-Test "jn (1, 2.0) == 0.57672480775687338720":
-double: 1
-idouble: 1
-Test "jn (1, 8.0) == 0.23463634685391462438":
-double: 1
-idouble: 1
-Test "jn (10, 0.1) == 0.26905328954342155795e-19":
-double: 6
-float: 4
-idouble: 6
-ifloat: 4
-Test "jn (10, 0.7) == 0.75175911502153953928e-11":
-double: 3
-float: 1
-idouble: 3
-ifloat: 1
-Test "jn (10, 10.0) == 0.20748610663335885770":
-double: 4
-float: 3
-idouble: 4
-ifloat: 3
-Test "jn (10, 2.0) == 0.25153862827167367096e-6":
-float: 4
-ifloat: 4
-Test "jn (3, 0.1) == 0.000020820315754756261429":
-double: 1
-idouble: 1
-Test "jn (3, 0.7) == 0.0069296548267508408077":
-float: 1
-ifloat: 1
-Test "jn (3, 10.0) == 0.058379379305186812343":
-double: 3
-float: 1
-idouble: 3
-ifloat: 1
-Test "jn (3, 2.0) == 0.12894324947440205110":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-# lgamma
-Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-# log
-Test "log (0.7) == -0.35667494393873237891263871124118447":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# log10
-Test "log10 (0.7) == -0.15490195998574316929":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "log10 (e) == log10(e)":
-float: 1
-ifloat: 1
-
-# log1p
-Test "log1p (-0.3) == -0.35667494393873237891263871124118447":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# log2
-Test "log2 (0.7) == -0.51457317282975824043":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# sincos
-Test "sincos (0.7, &sin_res, &cos_res) puts 0.76484218728448842626 in cos_res":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
-double: 1
-float: 0.5
-idouble: 1
-ifloat: 0.5
-Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.866025403784438646764 in sin_res":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
-double: 0.2758
-float: 0.3667
-idouble: 0.2758
-ifloat: 0.3667
-Test "sincos (pi/6, &sin_res, &cos_res) puts 0.866025403784438646764 in cos_res":
-float: 1
-ifloat: 1
-
-# sinh
-Test "sinh (0.7) == 0.75858370183953350346":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# tan
-Test "tan (pi/4) == 1":
-double: 0.5
-idouble: 0.5
-
-# tanh
-Test "tanh (0.7) == 0.60436777711716349631":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# tgamma
-Test "tgamma (-0.5) == -2 sqrt (pi)":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "tgamma (0.5) == sqrt (pi)":
-float: 1
-ifloat: 1
-Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# y0
-Test "y0 (0.7) == -0.19066492933739506743":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "y0 (1.0) == 0.088256964215676957983":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "y0 (1.5) == 0.38244892379775884396":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "y0 (10.0) == 0.055671167283599391424":
-float: 1
-ifloat: 1
-Test "y0 (8.0) == 0.22352148938756622053":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-# y1
-Test "y1 (0.1) == -6.4589510947020269877":
-double: 1
-idouble: 1
-Test "y1 (0.7) == -1.1032498719076333697":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "y1 (1.5) == -0.41230862697391129595":
-float: 1
-ifloat: 1
-Test "y1 (10.0) == 0.24901542420695388392":
-double: 3
-float: 1
-idouble: 3
-ifloat: 1
-Test "y1 (2.0) == -0.10703243154093754689":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "y1 (8.0) == -0.15806046173124749426":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-# yn
-Test "yn (0, 0.7) == -0.19066492933739506743":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "yn (0, 1.0) == 0.088256964215676957983":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "yn (0, 1.5) == 0.38244892379775884396":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-Test "yn (0, 10.0) == 0.055671167283599391424":
-float: 1
-ifloat: 1
-Test "yn (0, 8.0) == 0.22352148938756622053":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (1, 0.1) == -6.4589510947020269877":
-double: 1
-idouble: 1
-Test "yn (1, 0.7) == -1.1032498719076333697":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (1, 1.5) == -0.41230862697391129595":
-float: 1
-ifloat: 1
-Test "yn (1, 10.0) == 0.24901542420695388392":
-double: 3
-float: 1
-idouble: 3
-ifloat: 1
-Test "yn (1, 2.0) == -0.10703243154093754689":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (1, 8.0) == -0.15806046173124749426":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-Test "yn (10, 0.1) == -0.11831335132045197885e19":
-double: 2
-float: 2
-idouble: 2
-ifloat: 2
-Test "yn (10, 0.7) == -0.42447194260703866924e10":
-double: 3
-idouble: 3
-Test "yn (10, 1.0) == -0.12161801427868918929e9":
-double: 1
-idouble: 1
-Test "yn (10, 10.0) == -0.35981415218340272205":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (10, 2.0) == -129184.54220803928264":
-double: 2
-idouble: 2
-Test "yn (3, 0.1) == -5099.3323786129048894":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (3, 0.7) == -15.819479052819633505":
-double: 3
-float: 1
-idouble: 3
-ifloat: 1
-Test "yn (3, 10.0) == -0.25136265718383732978":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-Test "yn (3, 2.0) == -1.1277837768404277861":
-double: 1
-idouble: 1
-
-# Maximal error of functions:
-Function: "asin":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-Function: "atan2":
-float: 4
-ifloat: 4
-
-Function: "atanh":
-double: 1
-idouble: 1
-
-Function: "cabs":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "cacos":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "cacos":
-float: 1
-ifloat: 1
-
-Function: Real part of "cacosh":
-double: 1
-float: 7
-idouble: 1
-ifloat: 7
-
-Function: Imaginary part of "cacosh":
-double: 1
-float: 3
-idouble: 1
-ifloat: 3
-
-Function: Real part of "casin":
-double: 3
-float: 2
-idouble: 3
-ifloat: 2
-
-Function: Imaginary part of "casin":
-float: 1
-ifloat: 1
-
-Function: Real part of "casinh":
-double: 5
-float: 1
-idouble: 5
-ifloat: 1
-
-Function: Imaginary part of "casinh":
-double: 3
-float: 6
-idouble: 3
-ifloat: 6
-
-Function: Real part of "catan":
-float: 4
-ifloat: 4
-
-Function: Imaginary part of "catan":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "catanh":
-double: 4
-float: 1
-idouble: 4
-ifloat: 1
-
-Function: Imaginary part of "catanh":
-double: 1
-float: 6
-idouble: 1
-ifloat: 6
-
-Function: "cbrt":
-double: 1
-idouble: 1
-
-Function: Real part of "ccos":
-double: 1
-idouble: 1
-
-Function: Imaginary part of "ccos":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "ccosh":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "ccosh":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "cexp":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "cexp":
-float: 1
-ifloat: 1
-
-Function: Imaginary part of "clog":
-double: 1
-float: 3
-idouble: 1
-ifloat: 3
-
-Function: Real part of "clog10":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "clog10":
-double: 1
-float: 5
-idouble: 1
-ifloat: 5
-
-Function: "cos":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-Function: Real part of "cpow":
-double: 1
-float: 4
-idouble: 1
-ifloat: 4
-
-Function: Imaginary part of "cpow":
-double: 1.1031
-float: 2
-idouble: 1.1031
-ifloat: 2
-
-Function: Imaginary part of "csin":
-float: 1
-ifloat: 1
-
-Function: Real part of "csinh":
-float: 1
-ifloat: 1
-
-Function: Imaginary part of "csinh":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "csqrt":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "csqrt":
-float: 1
-ifloat: 1
-
-Function: Real part of "ctan":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Imaginary part of "ctan":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: Real part of "ctanh":
-double: 2
-float: 2
-idouble: 2
-ifloat: 2
-
-Function: Imaginary part of "ctanh":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-Function: "erfc":
-double: 24
-float: 12
-idouble: 24
-ifloat: 12
-
-Function: "exp10":
-double: 6
-float: 2
-idouble: 6
-ifloat: 2
-
-Function: "expm1":
-float: 1
-ifloat: 1
-
-Function: "fmod":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-Function: "hypot":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "j0":
-double: 2
-float: 2
-idouble: 2
-ifloat: 2
-
-Function: "j1":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-Function: "jn":
-double: 6
-float: 4
-idouble: 6
-ifloat: 4
-
-Function: "lgamma":
-double: 1
-float: 2
-idouble: 1
-ifloat: 2
-
-Function: "log":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "log10":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "log1p":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "log2":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "sincos":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "sinh":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "tan":
-double: 0.5
-idouble: 0.5
-
-Function: "tanh":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "tgamma":
-double: 1
-float: 1
-idouble: 1
-ifloat: 1
-
-Function: "y0":
-double: 2
-float: 1
-idouble: 2
-ifloat: 1
-
-Function: "y1":
-double: 3
-float: 2
-idouble: 3
-ifloat: 2
-
-Function: "yn":
-double: 3
-float: 2
-idouble: 3
-ifloat: 2
-
-# end of automatic generation