Changeset 15d0046 in mainline for uspace/lib/c


Ignore:
Timestamp:
2014-09-12T13:22:33Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b20126
Parents:
8db09e4 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Location:
uspace/lib/c
Files:
18 added
30 deleted
75 edited
11 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r8db09e4 r15d0046  
    5050-include arch/$(UARCH)/Makefile.inc
    5151
     52ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG)))
     53ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG)))
     54ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG)))
     55
     56PRE_DEPEND += $(ARCH_AUTOGENS_H)
     57EXTRA_CLEAN += $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S)
     58
    5259GENERIC_SOURCES = \
    5360        generic/libc.c \
     
    6572        generic/device/pio_window.c \
    6673        generic/device/clock_dev.c \
     74        generic/device/led_dev.c \
    6775        generic/dhcp.c \
    6876        generic/dnsr.c \
     
    9199        generic/io/input.c \
    92100        generic/io/io.c \
     101        generic/io/chardev.c \
     102        generic/io/chardev_srv.c \
    93103        generic/io/chargrid.c \
    94104        generic/io/output.c \
     
    108118        generic/iplink.c \
    109119        generic/iplink_srv.c \
     120        generic/irc.c \
     121        generic/irq.c \
    110122        generic/ieee_double.c \
    111123        generic/power_of_ten.c \
     
    159171include $(USPACE_PREFIX)/Makefile.common
    160172
     173%.h: %.ag
     174        $(AUTOGEN) probe $< >$<.probe.c
     175        $(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c
     176        $(AUTOGEN) generate $< <$<.probe.s >$@   
     177
    161178$(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
    162179        $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
  • uspace/lib/c/arch/amd64/Makefile.inc

    r8db09e4 r15d0046  
    3737        arch/$(UARCH)/src/stacktrace_asm.S
    3838
     39ARCH_AUTOGENS_AG = \
     40        arch/$(UARCH)/include/libarch/istate_struct.ag \
     41        arch/$(UARCH)/include/libarch/fibril_context.ag
     42
    3943.PRECIOUS: arch/$(UARCH)/src/entry.o
     44
  • uspace/lib/c/arch/amd64/include/libarch/fibril.h

    r8db09e4 r15d0046  
    3636#define LIBC_amd64_FIBRIL_H_
    3737
    38 #include <sys/types.h>
     38#include <libarch/fibril_context.h>
    3939
    4040/*
     
    5353        } while (0)
    5454
    55 /* We include only registers that must be preserved
    56  * during function call
    57  */
    58 typedef struct {
    59         uint64_t sp;
    60         uint64_t pc;
    61 
    62         uint64_t rbx;
    63         uint64_t rbp;
    64 
    65         uint64_t r12;
    66         uint64_t r13;
    67         uint64_t r14;
    68         uint64_t r15;
    69 
    70         uint64_t tls;
    71 } context_t;
    72 
    7355static inline uintptr_t context_get_fp(context_t *ctx)
    7456{
  • uspace/lib/c/arch/amd64/include/libarch/fibril_context.ag

    r8db09e4 r15d0046  
    1 #
    2 # Copyright (c) 2011 Jiri Zarevucky
     1# Copyright (c) 2014 Jakub Jermar
    32# All rights reserved.
    43#
     
    2726#
    2827
    29 USPACE_PREFIX = ../../../..
    30 MIPDIR = ../../mip
    31 MDIR = ../../arch/$(PLATFORM)
    32 OSDIR = ../../os/helenos
    33 EXTRA_CFLAGS = -I$(MIPDIR) -I$(MDIR) -I$(OSDIR) -I. -w
    34 DEFS = -Dmach_$(PLATFORM) -D__helenos__ -DPCC_DEBUG -DGCC_COMPAT -Dfree=free
    35 LIBS = $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
    36 BINARY = ccom
     28{
     29        name : context,
    3730
    38 PRE_DEPEND = cgram.c scan.c external.c external.h common.c compat.c
    39 EXTRA_CLEAN = cgram.c cgram.h scan.c external.c external.h common.c compat.c \
    40         $(MIPDIR)/*.o $(MDIR)/*.o
     31        includes : [
     32                {
     33                        include : <sys/types.h>
     34                }
     35        ],
    4136
    42 POSIX_COMPAT = y
     37        members : [
     38                #
     39                # We include only registers that must be preserved
     40                # during function call.
     41                #
    4342
    44 # FIXME: external.{c,h} must be generated for each target system
     43                {
     44                        name : sp,
     45                        type : uint64_t
     46                },
     47                {
     48                        name : pc,
     49                        type : uint64_t
     50                },
    4551
    46 SOURCES = \
    47         external.c \
    48         $(MDIR)/local.c \
    49         $(MDIR)/local2.c \
    50         $(MDIR)/code.c \
    51         $(MDIR)/order.c \
    52         $(MDIR)/table.c \
    53         $(MIPDIR)/match.c \
    54         $(MIPDIR)/reader.c \
    55         $(MIPDIR)/optim2.c \
    56         $(MIPDIR)/regs.c \
    57         common.c \
    58         compat.c \
    59         cgram.c \
    60         scan.c \
    61         builtins.c \
    62         gcc_compat.c \
    63         init.c \
    64         inline.c \
    65         main.c \
    66         optim.c \
    67         pftn.c \
    68         softfloat.c \
    69         stabs.c \
    70         symtabs.c \
    71         trees.c
     52                {
     53                        name : rbx,
     54                        type : uint64_t
     55                },
     56                {
     57                        name : rbp,
     58                        type : uint64_t
     59                },
    7260
    73 include $(USPACE_PREFIX)/Makefile.common
     61                {
     62                        name : r12,
     63                        type : uint64_t
     64                },
     65                {
     66                        name : r13,
     67                        type : uint64_t
     68                },
     69                {
     70                        name : r14,
     71                        type : uint64_t
     72                },
     73                {
     74                        name : r15,
     75                        type : uint64_t
     76                },
    7477
    75 cgram.c: cgram.y
    76         $(YACC) $(YFLAGS) -d $<
    77         mv y.tab.c cgram.c
    78         mv y.tab.h cgram.h
    79 
    80 scan.c: scan.l cgram.c
    81         $(LEX) $(LFLAGS) $<
    82         mv lex.yy.c scan.c
    83 
    84 compat.c: $(MIPDIR)/compat.c
    85         ln -s -f $^ $@
    86 
    87 common.c: $(MIPDIR)/common.c
    88         ln -s -f $^ $@
    89 
    90 external.c: arch/$(PLATFORM)/external.c
    91         ln -s -f $^ $@
    92 
    93 external.h: arch/$(PLATFORM)/external.h
    94         ln -s -f $^ $@
    95 
     78                {
     79                        name : tls,
     80                        type : uint64_t
     81                }
     82        ]
     83}
  • uspace/lib/c/arch/amd64/src/fibril.S

    r8db09e4 r15d0046  
    3232.global context_restore
    3333
    34 #include <libarch/context_offset.h>
     34#include <libarch/fibril_context.h>
    3535
    3636## Save current CPU context
     
    4242        movq (%rsp), %rdx     # the caller's return %eip
    4343       
    44         # in %edi is passed 1st argument
    45         CONTEXT_SAVE_ARCH_CORE %rdi %rdx
     44        # in %rdi is passed 1st argument
     45        movq %rdx, CONTEXT_OFFSET_PC(%rdi)
     46        movq %rsp, CONTEXT_OFFSET_SP(%rdi)
     47       
     48        movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
     49        movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
     50        movq %r12, CONTEXT_OFFSET_R12(%rdi)
     51        movq %r13, CONTEXT_OFFSET_R13(%rdi)
     52        movq %r14, CONTEXT_OFFSET_R14(%rdi)
     53        movq %r15, CONTEXT_OFFSET_R15(%rdi)
    4654       
    4755        # save TLS
    4856        movq %fs:0, %rax
    49         movq %rax, OFFSET_TLS(%rdi)
     57        movq %rax, CONTEXT_OFFSET_TLS(%rdi)
    5058       
    51         xorl %eax, %eax       # context_save returns 1
     59        xorl %eax, %eax                      # context_save returns 1
    5260        incl %eax
    5361        ret
     
    6068context_restore:
    6169       
    62         CONTEXT_RESTORE_ARCH_CORE %rdi %rdx
     70        movq CONTEXT_OFFSET_R15(%rdi), %r15
     71        movq CONTEXT_OFFSET_R14(%rdi), %r14
     72        movq CONTEXT_OFFSET_R13(%rdi), %r13
     73        movq CONTEXT_OFFSET_R12(%rdi), %r12
     74        movq CONTEXT_OFFSET_RBP(%rdi), %rbp
     75        movq CONTEXT_OFFSET_RBX(%rdi), %rbx
     76       
     77        movq CONTEXT_OFFSET_SP(%rdi), %rsp   # ctx->sp -> %rsp
     78       
     79        movq CONTEXT_OFFSET_PC(%rdi), %rdx
    6380       
    6481        movq %rdx,(%rsp)
    6582       
    6683        # Set thread local storage
    67         movq OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
    68         movl $1, %eax                # SYS_TLS_SET
     84        movq CONTEXT_OFFSET_TLS(%rdi), %rdi  # Set arg1 to TLS addr
     85        movl $1, %eax                        # SYS_TLS_SET
    6986        syscall
    7087       
    71         xorl %eax, %eax              # context_restore returns 0
     88        xorl %eax, %eax                      # context_restore returns 0
    7289        ret
     90
  • uspace/lib/c/arch/amd64/src/stacktrace.c

    r8db09e4 r15d0046  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/arm32/Makefile.inc

    r8db09e4 r15d0046  
    3939        arch/$(UARCH)/src/stacktrace_asm.S
    4040
     41ARCH_AUTOGENS_AG = \
     42        arch/$(UARCH)/include/libarch/istate_struct.ag \
     43        arch/$(UARCH)/include/libarch/fibril_context.ag
     44
    4145.PRECIOUS: arch/$(UARCH)/src/entry.o
     46
  • uspace/lib/c/arch/arm32/include/libarch/fibril.h

    r8db09e4 r15d0046  
    4040#include <align.h>
    4141#include <thread.h>
     42#include <libarch/fibril_context.h>
    4243
    4344/** Size of a stack item */
     
    6667        } while (0)
    6768
    68 /** Fibril context.
    69  *
    70  *  Only registers preserved accross function calls are included. r9 is used
    71  *  to store a TLS address. -ffixed-r9 gcc forces gcc not to use this
    72  *  register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain
    73  *  TLS address.
    74  */
    75 typedef struct  {
    76         uint32_t sp;
    77         uint32_t pc;
    78         uint32_t r4;
    79         uint32_t r5;
    80         uint32_t r6;
    81         uint32_t r7;
    82         uint32_t r8;
    83         uint32_t tls;   /* r9 */
    84         uint32_t r10;
    85         uint32_t fp;    /* r11 */
    86 } context_t;
    87 
    8869static inline uintptr_t context_get_fp(context_t *ctx)
    8970{
  • uspace/lib/c/arch/arm32/src/stacktrace.c

    r8db09e4 r15d0046  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/ia32/Makefile.inc

    r8db09e4 r15d0046  
    3939        arch/$(UARCH)/src/rtld/reloc.c
    4040
     41ARCH_AUTOGENS_AG = \
     42        arch/$(UARCH)/include/libarch/istate_struct.ag \
     43        arch/$(UARCH)/include/libarch/fibril_context.ag
     44
    4145.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ia32/include/libarch/fibril.h

    r8db09e4 r15d0046  
    3737
    3838#include <sys/types.h>
     39#include <libarch/fibril_context.h>
    3940
    4041/*
     
    5354        } while (0)
    5455
    55 /*
    56  * We include only registers that must be preserved
    57  * during function call
    58  */
    59 typedef struct {
    60         uint32_t sp;
    61         uint32_t pc;
    62        
    63         uint32_t ebx;
    64         uint32_t esi;
    65         uint32_t edi;
    66         uint32_t ebp;
    67        
    68         uint32_t tls;
    69 } context_t;
    70 
    7156static inline uintptr_t context_get_fp(context_t *ctx)
    7257{
  • uspace/lib/c/arch/ia32/include/libarch/fibril_context.ag

    r8db09e4 r15d0046  
    1 #
    2 # Copyright (c) 2011 Jiri Zarevucky
     1# Copyright (c) 2014 Jakub Jermar
    32# All rights reserved.
    43#
     
    2726#
    2827
    29 USPACE_PREFIX = ../../../../..
    30 MIPDIR = ../../../mip
    31 MDIR = ../../../arch/$(PLATFORM)
    32 OSDIR = ../../../os/helenos
    33 EXTRA_CFLAGS = -I$(MIPDIR) -I$(MDIR) -I$(OSDIR) -I. -w
    34 DEFS = -DGCC_COMPAT -DPCC_DEBUG -DMKEXT -Dmach_$(PLATFORM) -D__helenos__
    35 BINARY = cc_mkext
     28{
     29        name : context,
    3630
    37 POSIX_COMPAT = y
     31        includes : [
     32                {
     33                        include : <sys/types.h>
     34                }
     35        ],
    3836
    39 PRE_DEPEND = mkext.c table.c common.c
    40 EXTRA_CLEAN = mkext.c table.c common.c
     37        members : [
     38                #
     39                # We include only registers that must be preserved
     40                # during function call.
     41                #
    4142
    42 # FIXME: external.{c,h} must be generated for each target system
     43                {
     44                        name : sp,
     45                        type : uint32_t
     46                },
     47                {
     48                        name : pc,
     49                        type : uint32_t
     50                },
    4351
    44 SOURCES = \
    45         mkext.c \
    46         table.c \
    47         common.c
     52                {
     53                        name : ebx,
     54                        type : uint32_t
     55                },
     56                {
     57                        name : esi,
     58                        type : uint32_t
     59                },
     60                {
     61                        name : edi,
     62                        type : uint32_t
     63                },
     64                {
     65                        name : ebp,
     66                        type : uint32_t
     67                },
    4868
    49 include $(USPACE_PREFIX)/Makefile.common
    50 
    51 mkext.c: $(MIPDIR)/mkext.c
    52         ln -s -f $^ $@
    53 
    54 table.c: $(MDIR)/table.c
    55         ln -s -f $^ $@
    56 
    57 common.c: $(MIPDIR)/common.c
    58         ln -s -f $^ $@
    59 
     69                {
     70                        name : tls,
     71                        type : uint32_t
     72                }
     73        ]
     74}
  • uspace/lib/c/arch/ia32/src/fibril.S

    r8db09e4 r15d0046  
    2727#
    2828
    29 #include <libarch/context_offset.h>
     29#include <libarch/fibril_context.h>
    3030
    3131.text
     
    4444       
    4545        # save registers to the context structure
    46         CONTEXT_SAVE_ARCH_CORE %edx %eax
     46        movl %esp, CONTEXT_OFFSET_SP(%edx)      # %esp -> ctx->sp
     47        movl %eax, CONTEXT_OFFSET_PC(%edx)      # %eip -> ctx->pc
     48        movl %ebx, CONTEXT_OFFSET_EBX(%edx)     # %ebx -> ctx->ebx
     49        movl %esi, CONTEXT_OFFSET_ESI(%edx)     # %esi -> ctx->esi
     50        movl %edi, CONTEXT_OFFSET_EDI(%edx)     # %edi -> ctx->edi
     51        movl %ebp, CONTEXT_OFFSET_EBP(%edx)     # %ebp -> ctx->ebp
    4752       
    4853        # save TLS
    4954        movl %gs:0, %eax
    50         movl %eax, OFFSET_TLS(%edx)     # tls -> ctx->tls
     55        movl %eax, CONTEXT_OFFSET_TLS(%edx)     # tls -> ctx->tls
    5156       
    52         xorl %eax, %eax     # context_save returns 1
     57        xorl %eax, %eax         # context_save returns 1
    5358        incl %eax
    5459        ret
     
    6368       
    6469        # restore registers from the context structure
    65         CONTEXT_RESTORE_ARCH_CORE %eax %edx
     70        movl CONTEXT_OFFSET_SP(%eax),%esp       # ctx->sp -> %esp
     71        movl CONTEXT_OFFSET_PC(%eax),%edx       # ctx->pc -> \pc
     72        movl CONTEXT_OFFSET_EBX(%eax),%ebx      # ctx->ebx -> %ebx
     73        movl CONTEXT_OFFSET_ESI(%eax),%esi      # ctx->esi -> %esi
     74        movl CONTEXT_OFFSET_EDI(%eax),%edi      # ctx->edi -> %edi
     75        movl CONTEXT_OFFSET_EBP(%eax),%ebp      # ctx->ebp -> %ebp
    6676       
    6777        movl %edx, 0(%esp)  # ctx->pc -> saver's return %eip
     
    6979        # set thread local storage
    7080        pushl %edx
    71         movl OFFSET_TLS(%eax), %edx  # Set arg1 to TLS addr
    72         movl $1, %eax                # Syscall SYS_TLS_SET
     81        movl CONTEXT_OFFSET_TLS(%eax), %edx     # Set arg1 to TLS addr
     82        movl $1, %eax                           # Syscall SYS_TLS_SET
    7383        int $0x30
    7484        popl %edx
    7585       
    76         xorl %eax, %eax     # context_restore returns 0
     86        xorl %eax, %eax         # context_restore returns 0
    7787        ret
     88
  • uspace/lib/c/arch/ia32/src/stacktrace.c

    r8db09e4 r15d0046  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/ia64/Makefile.common

    r8db09e4 r15d0046  
    2727#
    2828
    29 #
    30 # FIXME:
    31 #
    32 # The -fno-selective-scheduling and -fno-selective-scheduling2 options
    33 # should be removed as soon as a bug in GCC concerning unchecked
    34 # speculative loads is fixed.
    35 #
    36 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53975 for reference.
    37 #
    38 
    39 GCC_CFLAGS += -fno-unwind-tables -fno-selective-scheduling -fno-selective-scheduling2
     29GCC_CFLAGS += -fno-unwind-tables
    4030
    4131ENDIANESS = LE
  • uspace/lib/c/arch/ia64/Makefile.inc

    r8db09e4 r15d0046  
    3838        arch/$(UARCH)/src/stacktrace_asm.S
    3939
     40ARCH_AUTOGENS_AG = \
     41        arch/$(UARCH)/include/libarch/istate_struct.ag \
     42        arch/$(UARCH)/include/libarch/fibril_context.ag
     43
    4044.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ia64/include/libarch/fibril.h

    r8db09e4 r15d0046  
    4040#include <libarch/stack.h>
    4141#include <libarch/types.h>
     42#include <libarch/fibril_context.h>
    4243
    4344/*
     
    6465        } while (0)
    6566
    66 /*
    67  * Only save registers that must be preserved across
    68  * function calls.
    69  */
    70 typedef struct context {
    71 
    72         /*
    73          * Application registers
    74          */
    75         uint64_t ar_pfs;
    76         uint64_t ar_unat_caller;
    77         uint64_t ar_unat_callee;
    78         uint64_t ar_rsc;
    79         uint64_t bsp;           /* ar_bsp */
    80         uint64_t ar_rnat;
    81         uint64_t ar_lc;
    82 
    83         /*
    84          * General registers
    85          */
    86         uint64_t r1;
    87         uint64_t r4;
    88         uint64_t r5;
    89         uint64_t r6;
    90         uint64_t r7;
    91         uint64_t sp;            /* r12 */
    92         uint64_t tp;            /* r13 */
    93        
    94         /*
    95          * Branch registers
    96          */
    97         uint64_t pc;            /* b0 */
    98         uint64_t b1;
    99         uint64_t b2;
    100         uint64_t b3;
    101         uint64_t b4;
    102         uint64_t b5;
    103 
    104         /*
    105          * Predicate registers
    106          */
    107         uint64_t pr;
    108 
    109         uint128_t f2 __attribute__ ((aligned(16)));
    110         uint128_t f3;
    111         uint128_t f4;
    112         uint128_t f5;
    113 
    114         uint128_t f16;
    115         uint128_t f17;
    116         uint128_t f18;
    117         uint128_t f19;
    118         uint128_t f20;
    119         uint128_t f21;
    120         uint128_t f22;
    121         uint128_t f23;
    122         uint128_t f24;
    123         uint128_t f25;
    124         uint128_t f26;
    125         uint128_t f27;
    126         uint128_t f28;
    127         uint128_t f29;
    128         uint128_t f30;
    129         uint128_t f31;
    130 
    131 } context_t;
    132 
    13367static inline uintptr_t context_get_fp(context_t *ctx)
    13468{
  • uspace/lib/c/arch/ia64/include/libarch/types.h

    r8db09e4 r15d0046  
    4949        uint64_t lo;
    5050        int64_t hi;
    51 } int128_t;
     51} __attribute__((aligned(16))) int128_t;
    5252
    5353typedef struct {
    5454        uint64_t lo;
    5555        uint64_t hi;
    56 } uint128_t;
     56} __attribute__((aligned(16))) uint128_t;
    5757
    5858typedef uint64_t sysarg_t;
  • uspace/lib/c/arch/ia64/src/fibril.S

    r8db09e4 r15d0046  
    2727#
    2828
     29#include <libarch/fibril_context.h>
     30
    2931.text
    3032
     
    3335
    3436context_save:
    35         alloc loc0 = ar.pfs, 1, 8, 0, 0
    36         mov loc1 = ar.unat      ;;
    37         /* loc2 */
     37        alloc loc0 = ar.pfs, 1, 49, 0, 0
     38        mov loc1 = ar.unat ;;
    3839        mov loc3 = ar.rsc
    3940
     
    5859
    5960        mov loc6 = ar.lc
     61
     62        add loc8 = CONTEXT_OFFSET_AR_PFS, in0
     63        add loc9 = CONTEXT_OFFSET_AR_UNAT_CALLER, in0
     64        add loc10 = CONTEXT_OFFSET_AR_UNAT_CALLEE, in0
     65        add loc11 = CONTEXT_OFFSET_AR_RSC, in0
     66        add loc12 = CONTEXT_OFFSET_BSP, in0
     67        add loc13 = CONTEXT_OFFSET_AR_RNAT, in0
     68        add loc14 = CONTEXT_OFFSET_AR_LC, in0
     69
     70        add loc15 = CONTEXT_OFFSET_R1, in0
     71        add loc16 = CONTEXT_OFFSET_R4, in0
     72        add loc17 = CONTEXT_OFFSET_R5, in0
     73        add loc18 = CONTEXT_OFFSET_R6, in0
     74        add loc19 = CONTEXT_OFFSET_R7, in0
     75        add loc20 = CONTEXT_OFFSET_SP, in0
     76        add loc21 = CONTEXT_OFFSET_TP, in0
     77
     78        add loc22 = CONTEXT_OFFSET_PC, in0
     79        add loc23 = CONTEXT_OFFSET_B1, in0
     80        add loc24 = CONTEXT_OFFSET_B2, in0
     81        add loc25 = CONTEXT_OFFSET_B3, in0
     82        add loc26 = CONTEXT_OFFSET_B4, in0
     83        add loc27 = CONTEXT_OFFSET_B5, in0
     84
     85        add loc28 = CONTEXT_OFFSET_PR, in0
     86
     87        add loc29 = CONTEXT_OFFSET_F2, in0
     88        add loc30 = CONTEXT_OFFSET_F3, in0
     89        add loc31 = CONTEXT_OFFSET_F4, in0
     90        add loc32 = CONTEXT_OFFSET_F5, in0
     91
     92        add loc33 = CONTEXT_OFFSET_F16, in0
     93        add loc34 = CONTEXT_OFFSET_F17, in0
     94        add loc35 = CONTEXT_OFFSET_F18, in0
     95        add loc36 = CONTEXT_OFFSET_F19, in0
     96        add loc37 = CONTEXT_OFFSET_F20, in0
     97        add loc38 = CONTEXT_OFFSET_F21, in0
     98        add loc39 = CONTEXT_OFFSET_F22, in0
     99        add loc40 = CONTEXT_OFFSET_F23, in0
     100        add loc41 = CONTEXT_OFFSET_F24, in0
     101        add loc42 = CONTEXT_OFFSET_F25, in0
     102        add loc43 = CONTEXT_OFFSET_F26, in0
     103        add loc44 = CONTEXT_OFFSET_F27, in0
     104        add loc45 = CONTEXT_OFFSET_F28, in0
     105        add loc46 = CONTEXT_OFFSET_F29, in0
     106        add loc47 = CONTEXT_OFFSET_F30, in0
     107        add loc48 = CONTEXT_OFFSET_F31, in0 ;;
     108
     109        /*
     110         * Save general registers including NaT bits
     111         */
     112        st8.spill [loc15] = r1 ;;
     113        st8.spill [loc16] = r4 ;;
     114        st8.spill [loc17] = r5 ;;
     115        st8.spill [loc18] = r6 ;;
     116        st8.spill [loc19] = r7 ;;
     117        st8.spill [loc20] = r12 ;;      /* save sp */
     118        st8.spill [loc21] = r13 ;;      /* save tp */
     119
     120        mov loc2 = ar.unat
    60121       
    61122        /*
    62123         * Save application registers
    63124         */
    64         st8 [in0] = loc0, 8     ;;      /* save ar.pfs */
    65         st8 [in0] = loc1, 8     ;;      /* save ar.unat (caller) */
    66         mov loc2 = in0          ;;
    67         add in0 = 8, in0        ;;      /* skip ar.unat (callee) */
    68         st8 [in0] = loc3, 8     ;;      /* save ar.rsc */
    69         st8 [in0] = loc4, 8     ;;      /* save ar.bsp */
    70         st8 [in0] = loc5, 8     ;;      /* save ar.rnat */
    71         st8 [in0] = loc6, 8     ;;      /* save ar.lc */
    72        
    73         /*
    74          * Save general registers including NaT bits
    75          */
    76         st8.spill [in0] = r1, 8         ;;
    77         st8.spill [in0] = r4, 8         ;;
    78         st8.spill [in0] = r5, 8         ;;
    79         st8.spill [in0] = r6, 8         ;;
    80         st8.spill [in0] = r7, 8         ;;
    81         st8.spill [in0] = r12, 8        ;;      /* save sp */
    82         st8.spill [in0] = r13, 8        ;;      /* save tp */
    83 
    84         mov loc3 = ar.unat              ;;
    85         st8 [loc2] = loc3               /* save ar.unat (callee) */
     125        st8 [loc8] = loc0       /* save ar.pfs */
     126        st8 [loc9] = loc1 ;;    /* save ar.unat (caller) */
     127        st8 [loc10] = loc2      /* save ar.unat (callee) */
     128        st8 [loc11] = loc3      /* save ar.rsc */
     129        st8 [loc12] = loc4      /* save ar.bsp */
     130        st8 [loc13] = loc5      /* save ar.rnat */
     131        st8 [loc14] = loc6 ;;   /* save ar.lc */
    86132
    87133        /*
    88134         * Save branch registers
    89135         */
    90         mov loc2 = b0           ;;
    91         st8 [in0] = loc2, 8             /* save pc */
    92         mov loc3 = b1           ;;
    93         st8 [in0] = loc3, 8
    94         mov loc4 = b2           ;;
    95         st8 [in0] = loc4, 8
    96         mov loc5 = b3           ;;
    97         st8 [in0] = loc5, 8
    98         mov loc6 = b4           ;;
    99         st8 [in0] = loc6, 8
    100         mov loc7 = b5           ;;
    101         st8 [in0] = loc7, 8
     136        mov loc2 = b0
     137        mov loc3 = b1
     138        mov loc4 = b2
     139        mov loc5 = b3
     140        mov loc6 = b4
     141        mov loc7 = b5 ;;
     142        st8 [loc22] = loc2      /* save pc */
     143        st8 [loc23] = loc3
     144        st8 [loc24] = loc4
     145        st8 [loc25] = loc5
     146        st8 [loc26] = loc6
     147        st8 [loc27] = loc7 ;;
    102148
    103149        /*
    104150         * Save predicate registers
    105151         */
    106         mov loc2 = pr           ;;
    107         st8 [in0] = loc2, 16;;          /* Next fpu registers should be spilled to 16B aligned address */
     152        mov loc2 = pr ;;
     153        st8 [loc28] = loc2
    108154
    109155        /*
    110156         * Save floating-point registers.
    111157         */
    112         stf.spill [in0] = f2, 16 ;;
    113         stf.spill [in0] = f3, 16 ;;
    114         stf.spill [in0] = f4, 16 ;;
    115         stf.spill [in0] = f5, 16 ;;
    116 
    117         stf.spill [in0] = f16, 16 ;;
    118         stf.spill [in0] = f17, 16 ;;
    119         stf.spill [in0] = f18, 16 ;;
    120         stf.spill [in0] = f19, 16 ;;
    121         stf.spill [in0] = f20, 16 ;;
    122         stf.spill [in0] = f21, 16 ;;
    123         stf.spill [in0] = f22, 16 ;;
    124         stf.spill [in0] = f23, 16 ;;
    125         stf.spill [in0] = f24, 16 ;;
    126         stf.spill [in0] = f25, 16 ;;
    127         stf.spill [in0] = f26, 16 ;;
    128         stf.spill [in0] = f27, 16 ;;
    129         stf.spill [in0] = f28, 16 ;;
    130         stf.spill [in0] = f29, 16 ;;
    131         stf.spill [in0] = f30, 16 ;;
    132         stf.spill [in0] = f31, 16 ;;   
     158        stf.spill [loc29] = f2
     159        stf.spill [loc30] = f3
     160        stf.spill [loc31] = f4
     161        stf.spill [loc32] = f5
     162
     163        stf.spill [loc33] = f16
     164        stf.spill [loc34] = f17
     165        stf.spill [loc35] = f18
     166        stf.spill [loc36] = f19
     167        stf.spill [loc37] = f20
     168        stf.spill [loc38] = f21
     169        stf.spill [loc39] = f22
     170        stf.spill [loc40] = f23
     171        stf.spill [loc41] = f24
     172        stf.spill [loc42] = f25
     173        stf.spill [loc43] = f26
     174        stf.spill [loc44] = f27
     175        stf.spill [loc45] = f28
     176        stf.spill [loc46] = f29
     177        stf.spill [loc47] = f30
     178        stf.spill [loc48] = f31
    133179
    134180        mov ar.unat = loc1
    135181       
    136         add r8 = r0, r0, 1              /* context_save returns 1 */
     182        add r8 = r0, r0, 1      /* context_save returns 1 */
    137183        br.ret.sptk.many b0
    138184
    139185context_restore:
    140         alloc loc0 = ar.pfs, 1, 9, 0, 0 ;;
    141 
    142         ld8 loc0 = [in0], 8     ;;      /* load ar.pfs */
    143         ld8 loc1 = [in0], 8     ;;      /* load ar.unat (caller) */
    144         ld8 loc2 = [in0], 8     ;;      /* load ar.unat (callee) */
    145         ld8 loc3 = [in0], 8     ;;      /* load ar.rsc */
    146         ld8 loc4 = [in0], 8     ;;      /* load ar.bsp */
    147         ld8 loc5 = [in0], 8     ;;      /* load ar.rnat */
    148         ld8 loc6 = [in0], 8     ;;      /* load ar.lc */
     186        alloc loc0 = ar.pfs, 1, 50, 0, 0        ;;
     187
     188        add loc9 = CONTEXT_OFFSET_AR_PFS, in0
     189        add loc10 = CONTEXT_OFFSET_AR_UNAT_CALLER, in0
     190        add loc11 = CONTEXT_OFFSET_AR_UNAT_CALLEE, in0
     191        add loc12 = CONTEXT_OFFSET_AR_RSC, in0
     192        add loc13 = CONTEXT_OFFSET_BSP, in0
     193        add loc14 = CONTEXT_OFFSET_AR_RNAT, in0
     194        add loc15 = CONTEXT_OFFSET_AR_LC, in0
     195
     196        add loc16 = CONTEXT_OFFSET_R1, in0
     197        add loc17 = CONTEXT_OFFSET_R4, in0
     198        add loc18 = CONTEXT_OFFSET_R5, in0
     199        add loc19 = CONTEXT_OFFSET_R6, in0
     200        add loc20 = CONTEXT_OFFSET_R7, in0
     201        add loc21 = CONTEXT_OFFSET_SP, in0
     202        add loc22 = CONTEXT_OFFSET_TP, in0
     203
     204        add loc23 = CONTEXT_OFFSET_PC, in0
     205        add loc24 = CONTEXT_OFFSET_B1, in0
     206        add loc25 = CONTEXT_OFFSET_B2, in0
     207        add loc26 = CONTEXT_OFFSET_B3, in0
     208        add loc27 = CONTEXT_OFFSET_B4, in0
     209        add loc28 = CONTEXT_OFFSET_B5, in0
     210
     211        add loc29 = CONTEXT_OFFSET_PR, in0
     212
     213        add loc30 = CONTEXT_OFFSET_F2, in0
     214        add loc31 = CONTEXT_OFFSET_F3, in0
     215        add loc32 = CONTEXT_OFFSET_F4, in0
     216        add loc33 = CONTEXT_OFFSET_F5, in0
     217
     218        add loc34 = CONTEXT_OFFSET_F16, in0
     219        add loc35 = CONTEXT_OFFSET_F17, in0
     220        add loc36 = CONTEXT_OFFSET_F18, in0
     221        add loc37 = CONTEXT_OFFSET_F19, in0
     222        add loc38 = CONTEXT_OFFSET_F20, in0
     223        add loc39 = CONTEXT_OFFSET_F21, in0
     224        add loc40 = CONTEXT_OFFSET_F22, in0
     225        add loc41 = CONTEXT_OFFSET_F23, in0
     226        add loc42 = CONTEXT_OFFSET_F24, in0
     227        add loc43 = CONTEXT_OFFSET_F25, in0
     228        add loc44 = CONTEXT_OFFSET_F26, in0
     229        add loc45 = CONTEXT_OFFSET_F27, in0
     230        add loc46 = CONTEXT_OFFSET_F28, in0
     231        add loc47 = CONTEXT_OFFSET_F29, in0
     232        add loc48 = CONTEXT_OFFSET_F30, in0
     233        add loc49 = CONTEXT_OFFSET_F31, in0 ;;
     234
     235        ld8 loc0 = [loc9]       /* load ar.pfs */
     236        ld8 loc1 = [loc10]      /* load ar.unat (caller) */
     237        ld8 loc2 = [loc11]      /* load ar.unat (callee) */
     238        ld8 loc3 = [loc12]      /* load ar.rsc */
     239        ld8 loc4 = [loc13]      /* load ar.bsp */
     240        ld8 loc5 = [loc14]      /* load ar.rnat */
     241        ld8 loc6 = [loc15]      /* load ar.lc */
    149242       
    150243        .auto   
     
    180273        .explicit
    181274
    182         mov ar.unat = loc2      ;;
     275        mov ar.unat = loc2 ;;
    183276        mov ar.lc = loc6
    184277       
     
    186279         * Restore general registers including NaT bits
    187280         */
    188         ld8.fill r1 = [in0], 8  ;;
    189         ld8.fill r4 = [in0], 8  ;;
    190         ld8.fill r5 = [in0], 8  ;;
    191         ld8.fill r6 = [in0], 8  ;;
    192         ld8.fill r7 = [in0], 8  ;;
    193         ld8.fill r12 = [in0], 8 ;;      /* restore sp */
    194         ld8.fill r13 = [in0], 8 ;;
     281        ld8.fill r1 = [loc16] ;;
     282        ld8.fill r4 = [loc17] ;;
     283        ld8.fill r5 = [loc18] ;;
     284        ld8.fill r6 = [loc19] ;;
     285        ld8.fill r7 = [loc20] ;;
     286        ld8.fill r12 = [loc21] ;;       /* restore sp */
     287        ld8.fill r13 = [loc22] ;;
    195288
    196289        /*
    197290         * Restore branch registers
    198291         */
    199         ld8 loc2 = [in0], 8     ;;      /* restore pc */
     292        ld8 loc2 = [loc23]              /* restore pc */
     293        ld8 loc3 = [loc24]
     294        ld8 loc4 = [loc25]
     295        ld8 loc5 = [loc26]
     296        ld8 loc6 = [loc27]
     297        ld8 loc7 = [loc28] ;;
    200298        mov b0 = loc2
    201         ld8 loc3 = [in0], 8     ;;
    202299        mov b1 = loc3
    203         ld8 loc4 = [in0], 8     ;;
    204300        mov b2 = loc4
    205         ld8 loc5 = [in0], 8     ;;
    206301        mov b3 = loc5
    207         ld8 loc6 = [in0], 8     ;;
    208302        mov b4 = loc6
    209         ld8 loc7 = [in0], 8     ;;
    210         mov b5 = loc7
     303        mov b5 = loc7 ;;
    211304
    212305        /*
    213306         * Restore predicate registers
    214307         */
    215         ld8 loc2 = [in0], 16    ;;
     308        ld8 loc2 = [loc29] ;;
    216309        mov pr = loc2, ~0
    217310
     
    219312         * Restore floating-point registers.
    220313         */
    221         ldf.fill f2 = [in0], 16 ;;
    222         ldf.fill f3 = [in0], 16 ;;
    223         ldf.fill f4 = [in0], 16 ;;
    224         ldf.fill f5 = [in0], 16 ;;
    225 
    226         ldf.fill f16 = [in0], 16 ;;
    227         ldf.fill f17 = [in0], 16 ;;
    228         ldf.fill f18 = [in0], 16 ;;
    229         ldf.fill f19 = [in0], 16 ;;
    230         ldf.fill f20 = [in0], 16 ;;
    231         ldf.fill f21 = [in0], 16 ;;
    232         ldf.fill f22 = [in0], 16 ;;
    233         ldf.fill f23 = [in0], 16 ;;
    234         ldf.fill f24 = [in0], 16 ;;
    235         ldf.fill f25 = [in0], 16 ;;
    236         ldf.fill f26 = [in0], 16 ;;
    237         ldf.fill f27 = [in0], 16 ;;
    238         ldf.fill f28 = [in0], 16 ;;
    239         ldf.fill f29 = [in0], 16 ;;
    240         ldf.fill f30 = [in0], 16 ;;
    241         ldf.fill f31 = [in0], 16 ;;
     314        ldf.fill f2 = [loc30]
     315        ldf.fill f3 = [loc31]
     316        ldf.fill f4 = [loc32]
     317        ldf.fill f5 = [loc33]
     318
     319        ldf.fill f16 = [loc34]
     320        ldf.fill f17 = [loc35]
     321        ldf.fill f18 = [loc36]
     322        ldf.fill f19 = [loc37]
     323        ldf.fill f20 = [loc38]
     324        ldf.fill f21 = [loc39]
     325        ldf.fill f22 = [loc40]
     326        ldf.fill f23 = [loc41]
     327        ldf.fill f24 = [loc42]
     328        ldf.fill f25 = [loc43]
     329        ldf.fill f26 = [loc44]
     330        ldf.fill f27 = [loc45]
     331        ldf.fill f28 = [loc46]
     332        ldf.fill f29 = [loc47]
     333        ldf.fill f30 = [loc48]
     334        ldf.fill f31 = [loc49]
    242335       
    243336        mov ar.unat = loc1
  • uspace/lib/c/arch/mips32/Makefile.inc

    r8db09e4 r15d0046  
    3737        arch/$(UARCH)/src/stacktrace_asm.S
    3838
     39ARCH_AUTOGENS_AG = \
     40        arch/$(UARCH)/include/libarch/istate_struct.ag \
     41        arch/$(UARCH)/include/libarch/fibril_context.ag
     42
    3943.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/mips32/include/libarch/fibril.h

    r8db09e4 r15d0046  
    3838
    3939#include <sys/types.h>
     40#include <libarch/fibril_context.h>
    4041#include <libarch/stack.h>
    4142#include <align.h>
     
    5657        } while (0)
    5758
    58 typedef struct  {
    59         uint32_t sp;
    60         uint32_t pc;
    61        
    62         uint32_t s0;
    63         uint32_t s1;
    64         uint32_t s2;
    65         uint32_t s3;
    66         uint32_t s4;
    67         uint32_t s5;
    68         uint32_t s6;
    69         uint32_t s7;
    70         uint32_t s8;
    71         uint32_t gp;
    72         uint32_t tls; /* Thread local storage(=k1) */
    73 
    74         uint32_t f20;
    75         uint32_t f21;
    76         uint32_t f22;
    77         uint32_t f23;
    78         uint32_t f24;
    79         uint32_t f25;
    80         uint32_t f26;
    81         uint32_t f27;
    82         uint32_t f28;
    83         uint32_t f29;
    84         uint32_t f30;
    85        
    86 } context_t;
    87 
    8859static inline uintptr_t context_get_fp(context_t *ctx)
    8960{
  • uspace/lib/c/arch/mips32/src/fibril.S

    r8db09e4 r15d0046  
    3232.set noreorder
    3333
    34 #include <libarch/context_offset.h>
     34#include <libarch/fibril_context.h>
    3535
    3636.global context_save
     
    3838
    3939context_save:
    40         CONTEXT_SAVE_ARCH_CORE $a0
     40        sw $s0, CONTEXT_OFFSET_S0($a0)
     41        sw $s1, CONTEXT_OFFSET_S1($a0)
     42        sw $s2, CONTEXT_OFFSET_S2($a0)
     43        sw $s3, CONTEXT_OFFSET_S3($a0)
     44        sw $s4, CONTEXT_OFFSET_S4($a0)
     45        sw $s5, CONTEXT_OFFSET_S5($a0)
     46        sw $s6, CONTEXT_OFFSET_S6($a0)
     47        sw $s7, CONTEXT_OFFSET_S7($a0)
     48        sw $s8, CONTEXT_OFFSET_S8($a0)
     49        sw $gp, CONTEXT_OFFSET_GP($a0)
     50       
     51        sw $k1, CONTEXT_OFFSET_TLS($a0)
     52       
     53#ifdef CONFIG_FPU
     54        mfc1 $t0, $20
     55        sw $t0, CONTEXT_OFFSET_F20($a0)
     56       
     57        mfc1 $t0, $21
     58        sw $t0, CONTEXT_OFFSET_F21($a0)
     59       
     60        mfc1 $t0, $22
     61        sw $t0, CONTEXT_OFFSET_F22($a0)
     62       
     63        mfc1 $t0, $23
     64        sw $t0, CONTEXT_OFFSET_F23($a0)
     65       
     66        mfc1 $t0, $24
     67        sw $t0, CONTEXT_OFFSET_F24($a0)
     68       
     69        mfc1 $t0, $25
     70        sw $t0, CONTEXT_OFFSET_F25($a0)
     71       
     72        mfc1 $t0, $26
     73        sw $t0, CONTEXT_OFFSET_F26($a0)
     74       
     75        mfc1 $t0, $27
     76        sw $t0, CONTEXT_OFFSET_F27($a0)
     77       
     78        mfc1 $t0, $28
     79        sw $t0, CONTEXT_OFFSET_F28($a0)
     80       
     81        mfc1 $t0, $29
     82        sw $t0, CONTEXT_OFFSET_F29($a0)
     83       
     84        mfc1 $t0, $30
     85        sw $t0, CONTEXT_OFFSET_F30($a0)
     86#endif /* CONFIG_FPU */
     87       
     88        sw $ra, CONTEXT_OFFSET_PC($a0)
     89        sw $sp, CONTEXT_OFFSET_SP($a0)
    4190       
    4291        # context_save returns 1
     
    4594
    4695context_restore:
    47         CONTEXT_RESTORE_ARCH_CORE $a0
     96        lw $s0, CONTEXT_OFFSET_S0($a0)
     97        lw $s1, CONTEXT_OFFSET_S1($a0)
     98        lw $s2, CONTEXT_OFFSET_S2($a0)
     99        lw $s3, CONTEXT_OFFSET_S3($a0)
     100        lw $s4, CONTEXT_OFFSET_S4($a0)
     101        lw $s5, CONTEXT_OFFSET_S5($a0)
     102        lw $s6, CONTEXT_OFFSET_S6($a0)
     103        lw $s7, CONTEXT_OFFSET_S7($a0)
     104        lw $s8, CONTEXT_OFFSET_S8($a0)
     105        lw $gp, CONTEXT_OFFSET_GP($a0)
     106        lw $k1, CONTEXT_OFFSET_TLS($a0)
     107       
     108#ifdef CONFIG_FPU
     109        lw $t0, CONTEXT_OFFSET_F20($a0)
     110        mtc1 $t0, $20
     111       
     112        lw $t0, CONTEXT_OFFSET_F21($a0)
     113        mtc1 $t0, $21
     114       
     115        lw $t0, CONTEXT_OFFSET_F22($a0)
     116        mtc1 $t0, $22
     117       
     118        lw $t0, CONTEXT_OFFSET_F23($a0)
     119        mtc1 $t0, $23
     120       
     121        lw $t0, CONTEXT_OFFSET_F24($a0)
     122        mtc1 $t0, $24
     123       
     124        lw $t0, CONTEXT_OFFSET_F25($a0)
     125        mtc1 $t0, $25
     126       
     127        lw $t0, CONTEXT_OFFSET_F26($a0)
     128        mtc1 $t0, $26
     129       
     130        lw $t0, CONTEXT_OFFSET_F27($a0)
     131        mtc1 $t0, $27
     132       
     133        lw $t0, CONTEXT_OFFSET_F28($a0)
     134        mtc1 $t0, $28
     135       
     136        lw $t0, CONTEXT_OFFSET_F29($a0)
     137        mtc1 $t0, $29
     138       
     139        lw $t0, CONTEXT_OFFSET_F30($a0)
     140        mtc1 $t0, $30
     141#endif /* CONFIG_FPU */
     142       
     143        lw $ra, CONTEXT_OFFSET_PC($a0)
     144        lw $sp, CONTEXT_OFFSET_SP($a0)
    48145       
    49146        # Just for the jump into first function,
  • uspace/lib/c/arch/mips32eb/Makefile.inc

    r8db09e4 r15d0046  
    3737        arch/$(UARCH)/src/stacktrace_asm.S
    3838
     39ARCH_AUTOGENS_AG = \
     40        arch/$(UARCH)/include/libarch/istate_struct.ag \
     41        arch/$(UARCH)/include/libarch/fibril_context.ag
     42
    3943.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ppc32/Makefile.common

    r8db09e4 r15d0046  
    2727#
    2828
    29 GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
     29
     30ifeq ($(CONFIG_FPU),y)
     31FLOATS=hard
     32else
     33FLOATS=soft
     34endif
     35
     36GCC_CFLAGS += -mcpu=powerpc -m$(FLOATS)-float -m32
    3037BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
    3138AFLAGS = -a32
  • uspace/lib/c/arch/ppc32/Makefile.inc

    r8db09e4 r15d0046  
    3737        arch/$(UARCH)/src/stacktrace_asm.S
    3838
     39ARCH_AUTOGENS_AG = \
     40        arch/$(UARCH)/include/libarch/istate_struct.ag \
     41        arch/$(UARCH)/include/libarch/fibril_context.ag
     42
    3943.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ppc32/include/libarch/fibril.h

    r8db09e4 r15d0046  
    3737
    3838#include <sys/types.h>
     39#include <libarch/fibril_context.h>
    3940
    4041#define SP_DELTA  16
     
    5354        } while (0)
    5455
    55 typedef struct {
    56         uint32_t sp;
    57         uint32_t pc;
    58        
    59         uint32_t tls;
    60         uint32_t r13;
    61         uint32_t r14;
    62         uint32_t r15;
    63         uint32_t r16;
    64         uint32_t r17;
    65         uint32_t r18;
    66         uint32_t r19;
    67         uint32_t r20;
    68         uint32_t r21;
    69         uint32_t r22;
    70         uint32_t r23;
    71         uint32_t r24;
    72         uint32_t r25;
    73         uint32_t r26;
    74         uint32_t r27;
    75         uint32_t r28;
    76         uint32_t r29;
    77         uint32_t r30;
    78         uint32_t r31;
    79        
    80         uint32_t cr;
    81 } __attribute__ ((packed)) context_t;
    82 
    8356static inline uintptr_t context_get_fp(context_t *ctx)
    8457{
  • uspace/lib/c/arch/ppc32/src/fibril.S

    r8db09e4 r15d0046  
    3333
    3434#include <libarch/regname.h>
    35 #include <libarch/context_offset.h>
     35#include <libarch/fibril_context.h>
    3636
    3737context_save:
    38         CONTEXT_SAVE_ARCH_CORE r3
     38        stw sp, CONTEXT_OFFSET_SP(r3)
     39        stw r2, CONTEXT_OFFSET_TLS(r3)
     40        stw r13, CONTEXT_OFFSET_R13(r3)
     41        stw r14, CONTEXT_OFFSET_R14(r3)
     42        stw r15, CONTEXT_OFFSET_R15(r3)
     43        stw r16, CONTEXT_OFFSET_R16(r3)
     44        stw r17, CONTEXT_OFFSET_R17(r3)
     45        stw r18, CONTEXT_OFFSET_R18(r3)
     46        stw r19, CONTEXT_OFFSET_R19(r3)
     47        stw r20, CONTEXT_OFFSET_R20(r3)
     48        stw r21, CONTEXT_OFFSET_R21(r3)
     49        stw r22, CONTEXT_OFFSET_R22(r3)
     50        stw r23, CONTEXT_OFFSET_R23(r3)
     51        stw r24, CONTEXT_OFFSET_R24(r3)
     52        stw r25, CONTEXT_OFFSET_R25(r3)
     53        stw r26, CONTEXT_OFFSET_R26(r3)
     54        stw r27, CONTEXT_OFFSET_R27(r3)
     55        stw r28, CONTEXT_OFFSET_R28(r3)
     56        stw r29, CONTEXT_OFFSET_R29(r3)
     57        stw r30, CONTEXT_OFFSET_R30(r3)
     58        stw r31, CONTEXT_OFFSET_R31(r3)
    3959       
    4060        mflr r4
    41         stw r4, OFFSET_PC(r3)
     61        stw r4, CONTEXT_OFFSET_PC(r3)
    4262       
    4363        mfcr r4
    44         stw r4, OFFSET_CR(r3)
     64        stw r4, CONTEXT_OFFSET_CR(r3)
    4565       
    4666        # context_save returns 1
     
    5070
    5171context_restore:
    52         CONTEXT_RESTORE_ARCH_CORE r3
     72        lwz sp, CONTEXT_OFFSET_SP(r3)
     73        lwz r2, CONTEXT_OFFSET_TLS(r3)
     74        lwz r13, CONTEXT_OFFSET_R13(r3)
     75        lwz r14, CONTEXT_OFFSET_R14(r3)
     76        lwz r15, CONTEXT_OFFSET_R15(r3)
     77        lwz r16, CONTEXT_OFFSET_R16(r3)
     78        lwz r17, CONTEXT_OFFSET_R17(r3)
     79        lwz r18, CONTEXT_OFFSET_R18(r3)
     80        lwz r19, CONTEXT_OFFSET_R19(r3)
     81        lwz r20, CONTEXT_OFFSET_R20(r3)
     82        lwz r21, CONTEXT_OFFSET_R21(r3)
     83        lwz r22, CONTEXT_OFFSET_R22(r3)
     84        lwz r23, CONTEXT_OFFSET_R23(r3)
     85        lwz r24, CONTEXT_OFFSET_R24(r3)
     86        lwz r25, CONTEXT_OFFSET_R25(r3)
     87        lwz r26, CONTEXT_OFFSET_R26(r3)
     88        lwz r27, CONTEXT_OFFSET_R27(r3)
     89        lwz r28, CONTEXT_OFFSET_R28(r3)
     90        lwz r29, CONTEXT_OFFSET_R29(r3)
     91        lwz r30, CONTEXT_OFFSET_R30(r3)
     92        lwz r31, CONTEXT_OFFSET_R31(r3)
    5393       
    54         lwz r4, OFFSET_CR(r3)
     94        lwz r4, CONTEXT_OFFSET_CR(r3)
    5595        mtcr r4
    5696       
    57         lwz r4, OFFSET_PC(r3)
     97        lwz r4, CONTEXT_OFFSET_PC(r3)
    5898        mtlr r4
    5999       
  • uspace/lib/c/arch/ppc32/src/stacktrace.c

    r8db09e4 r15d0046  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/sparc32/src/stacktrace.c

    r8db09e4 r15d0046  
    5353{
    5454        uintptr_t bprev;
    55         int rc = (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,
     55        int rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,
    5656            &bprev);
    5757        if (rc == EOK)
     
    6363int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    6464{
    65         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     65        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    6666}
    6767
  • uspace/lib/c/arch/sparc64/Makefile.inc

    r8db09e4 r15d0046  
    3636        arch/$(UARCH)/src/stacktrace_asm.S
    3737
     38ARCH_AUTOGENS_AG = \
     39        arch/$(UARCH)/include/libarch/istate_struct.ag \
     40        arch/$(UARCH)/include/libarch/fibril_context.ag
     41
    3842.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/sparc64/_link.ld.in

    r8db09e4 r15d0046  
    1010#endif
    1111        data PT_LOAD FLAGS(6);
     12        debug PT_NOTE;
    1213}
    1314
     
    6364        } :data
    6465       
     66#ifdef CONFIG_LINE_DEBUG
     67        .comment 0 : { *(.comment); } :debug
     68        .debug_abbrev 0 : { *(.debug_abbrev); } :debug
     69        .debug_aranges 0 : { *(.debug_aranges); } :debug
     70        .debug_info 0 : { *(.debug_info); } :debug
     71        .debug_line 0 : { *(.debug_line); } :debug
     72        .debug_loc 0 : { *(.debug_loc); } :debug
     73        .debug_pubnames 0 : { *(.debug_pubnames); } :debug
     74        .debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
     75        .debug_ranges 0 : { *(.debug_ranges); } :debug
     76        .debug_str 0 : { *(.debug_str); } :debug
     77#endif
     78       
    6579        /DISCARD/ : {
    6680                *(*);
  • uspace/lib/c/arch/sparc64/include/libarch/fibril.h

    r8db09e4 r15d0046  
    3737
    3838#include <libarch/stack.h>
     39#include <libarch/fibril_context.h>
    3940#include <sys/types.h>
    4041#include <align.h>
     
    5152        } while (0)
    5253
    53 /*
    54  * Save only registers that must be preserved across
    55  * function calls.
    56  */
    57 typedef struct {
    58         uintptr_t sp;           /* %o6 */
    59         uintptr_t pc;           /* %o7 */
    60         uint64_t i0;
    61         uint64_t i1;
    62         uint64_t i2;
    63         uint64_t i3;
    64         uint64_t i4;
    65         uint64_t i5;
    66         uintptr_t fp;           /* %i6 */
    67         uintptr_t i7;
    68         uint64_t l0;
    69         uint64_t l1;
    70         uint64_t l2;
    71         uint64_t l3;
    72         uint64_t l4;
    73         uint64_t l5;
    74         uint64_t l6;
    75         uint64_t l7;
    76         uint64_t tp;            /* %g7 */
    77 } context_t;
    78 
    7954static inline uintptr_t context_get_fp(context_t *ctx)
    8055{
  • uspace/lib/c/arch/sparc64/src/fibril.S

    r8db09e4 r15d0046  
    2727#
    2828
    29 #include <libarch/context_offset.h>
     29#include <libarch/fibril_context.h>
    3030
    3131.text
     
    3939        # should a thread switch occur.
    4040        #
    41         CONTEXT_SAVE_ARCH_CORE %o0
     41        stx %sp, [%o0 + CONTEXT_OFFSET_SP]
     42        stx %o7, [%o0 + CONTEXT_OFFSET_PC]
     43        stx %i0, [%o0 + CONTEXT_OFFSET_I0]
     44        stx %i1, [%o0 + CONTEXT_OFFSET_I1]
     45        stx %i2, [%o0 + CONTEXT_OFFSET_I2]
     46        stx %i3, [%o0 + CONTEXT_OFFSET_I3]
     47        stx %i4, [%o0 + CONTEXT_OFFSET_I4]
     48        stx %i5, [%o0 + CONTEXT_OFFSET_I5]
     49        stx %fp, [%o0 + CONTEXT_OFFSET_FP]
     50        stx %i7, [%o0 + CONTEXT_OFFSET_I7]
     51        stx %l0, [%o0 + CONTEXT_OFFSET_L0]
     52        stx %l1, [%o0 + CONTEXT_OFFSET_L1]
     53        stx %l2, [%o0 + CONTEXT_OFFSET_L2]
     54        stx %l3, [%o0 + CONTEXT_OFFSET_L3]
     55        stx %l4, [%o0 + CONTEXT_OFFSET_L4]
     56        stx %l5, [%o0 + CONTEXT_OFFSET_L5]
     57        stx %l6, [%o0 + CONTEXT_OFFSET_L6]
     58        stx %l7, [%o0 + CONTEXT_OFFSET_L7]
     59        stx %g7, [%o0 + CONTEXT_OFFSET_TP]
    4260        retl
    4361        mov 1, %o0              ! context_save_arch returns 1
     
    5270        flushw
    5371       
    54         CONTEXT_RESTORE_ARCH_CORE %o0
     72        ldx [%o0 + CONTEXT_OFFSET_SP], %sp
     73        ldx [%o0 + CONTEXT_OFFSET_PC], %o7
     74        ldx [%o0 + CONTEXT_OFFSET_I0], %i0
     75        ldx [%o0 + CONTEXT_OFFSET_I1], %i1
     76        ldx [%o0 + CONTEXT_OFFSET_I2], %i2
     77        ldx [%o0 + CONTEXT_OFFSET_I3], %i3
     78        ldx [%o0 + CONTEXT_OFFSET_I4], %i4
     79        ldx [%o0 + CONTEXT_OFFSET_I5], %i5
     80        ldx [%o0 + CONTEXT_OFFSET_FP], %fp
     81        ldx [%o0 + CONTEXT_OFFSET_I7], %i7
     82        ldx [%o0 + CONTEXT_OFFSET_L0], %l0
     83        ldx [%o0 + CONTEXT_OFFSET_L1], %l1
     84        ldx [%o0 + CONTEXT_OFFSET_L2], %l2
     85        ldx [%o0 + CONTEXT_OFFSET_L3], %l3
     86        ldx [%o0 + CONTEXT_OFFSET_L4], %l4
     87        ldx [%o0 + CONTEXT_OFFSET_L5], %l5
     88        ldx [%o0 + CONTEXT_OFFSET_L6], %l6
     89        ldx [%o0 + CONTEXT_OFFSET_L7], %l7
     90        ldx [%o0 + CONTEXT_OFFSET_TP], %g7
    5591        retl
    5692        xor %o0, %o0, %o0       ! context_restore_arch returns 0
  • uspace/lib/c/arch/sparc64/src/stacktrace.c

    r8db09e4 r15d0046  
    5555        int rc;
    5656
    57         rc = (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);
     57        rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);
    5858        if (rc == EOK)
    5959                *prev = bprev + STACK_BIAS;
     
    6363int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    6464{
    65         return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     65        return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    6666}
    6767
  • uspace/lib/c/generic/adt/hash_table.c

    r8db09e4 r15d0046  
    370370                         */
    371371                        if (!f(cur_link, arg))
    372                                 return;
    373                 }
    374         }
    375        
     372                                goto out;
     373                }
     374        }
     375out:
    376376        h->apply_ongoing = false;
    377377       
  • uspace/lib/c/generic/async.c

    r8db09e4 r15d0046  
    101101#undef LIBC_ASYNC_C_
    102102
     103#include <ipc/irq.h>
     104#include <ipc/event.h>
    103105#include <futex.h>
    104106#include <fibril.h>
     
    116118#include "private/libc.h"
    117119
    118 
    119120/** Session data */
    120121struct async_sess {
     
    242243        async_client_conn_t cfibril;
    243244} connection_t;
     245
     246/* Notification data */
     247typedef struct {
     248        ht_link_t link;
     249       
     250        /** Notification method */
     251        sysarg_t imethod;
     252       
     253        /** Notification handler */
     254        async_notification_handler_t handler;
     255       
     256        /** Notification data */
     257        void *data;
     258} notification_t;
    244259
    245260/** Identifier of the incoming connection handled by the current fibril. */
     
    335350}
    336351
    337 /** Default fibril function that gets called to handle interrupt notifications.
    338  *
    339  * This function is defined as a weak symbol - to be redefined in user code.
    340  *
    341  * @param callid Hash of the incoming call.
    342  * @param call   Data of the incoming call.
    343  * @param arg    Local argument.
    344  *
    345  */
    346 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)
    347 {
    348 }
    349 
    350352static async_client_conn_t client_connection = default_client_connection;
    351 static async_interrupt_handler_t interrupt_received = default_interrupt_received;
    352 static size_t interrupt_handler_stksz = FIBRIL_DFLT_STK_SIZE;
     353static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE;
    353354
    354355/** Setter for client_connection function pointer.
     
    363364}
    364365
    365 /** Setter for interrupt_received function pointer.
    366  *
    367  * @param intr Function that will implement a new interrupt
    368  *             notification fibril.
    369  */
    370 void async_set_interrupt_received(async_interrupt_handler_t intr)
    371 {
    372         interrupt_received = intr;
    373 }
    374 
    375 /** Set the stack size for the interrupt handler notification fibrils.
     366/** Set the stack size for the notification handler notification fibrils.
    376367 *
    377368 * @param size Stack size in bytes.
    378369 */
    379 void async_set_interrupt_handler_stack_size(size_t size)
    380 {
    381         interrupt_handler_stksz = size;
     370void async_set_notification_handler_stack_size(size_t size)
     371{
     372        notification_handler_stksz = size;
    382373}
    383374
     
    399390static hash_table_t client_hash_table;
    400391static hash_table_t conn_hash_table;
     392static hash_table_t notification_hash_table;
    401393static LIST_INITIALIZE(timeout_list);
    402394
    403 static size_t client_key_hash(void *k)
    404 {
    405         task_id_t key = *(task_id_t*)k;
    406         return key;
     395static sysarg_t notification_avail = 0;
     396
     397static size_t client_key_hash(void *key)
     398{
     399        task_id_t in_task_id = *(task_id_t *) key;
     400        return in_task_id;
    407401}
    408402
     
    413407}
    414408
    415 static bool client_key_equal(void *k, const ht_link_t *item)
    416 {
    417         task_id_t key = *(task_id_t*)k;
     409static bool client_key_equal(void *key, const ht_link_t *item)
     410{
     411        task_id_t in_task_id = *(task_id_t *) key;
    418412        client_t *client = hash_table_get_inst(item, client_t, link);
    419         return key == client->in_task_id;
    420 }
    421 
     413        return in_task_id == client->in_task_id;
     414}
    422415
    423416/** Operations for the client hash table. */
     
    439432static size_t conn_key_hash(void *key)
    440433{
    441         sysarg_t in_phone_hash  = *(sysarg_t*)key;
    442         return in_phone_hash ;
     434        sysarg_t in_phone_hash = *(sysarg_t *) key;
     435        return in_phone_hash;
    443436}
    444437
     
    451444static bool conn_key_equal(void *key, const ht_link_t *item)
    452445{
    453         sysarg_t in_phone_hash = *(sysarg_t*)key;
     446        sysarg_t in_phone_hash = *(sysarg_t *) key;
    454447        connection_t *conn = hash_table_get_inst(item, connection_t, link);
    455448        return (in_phone_hash == conn->in_phone_hash);
    456449}
    457 
    458450
    459451/** Operations for the connection hash table. */
     
    462454        .key_hash = conn_key_hash,
    463455        .key_equal = conn_key_equal,
     456        .equal = NULL,
     457        .remove_callback = NULL
     458};
     459
     460static size_t notification_key_hash(void *key)
     461{
     462        sysarg_t id = *(sysarg_t *) key;
     463        return id;
     464}
     465
     466static size_t notification_hash(const ht_link_t *item)
     467{
     468        notification_t *notification =
     469            hash_table_get_inst(item, notification_t, link);
     470        return notification_key_hash(&notification->imethod);
     471}
     472
     473static bool notification_key_equal(void *key, const ht_link_t *item)
     474{
     475        sysarg_t id = *(sysarg_t *) key;
     476        notification_t *notification =
     477            hash_table_get_inst(item, notification_t, link);
     478        return id == notification->imethod;
     479}
     480
     481/** Operations for the notification hash table. */
     482static hash_table_ops_t notification_hash_table_ops = {
     483        .hash = notification_hash,
     484        .key_hash = notification_key_hash,
     485        .key_equal = notification_key_equal,
    464486        .equal = NULL,
    465487        .remove_callback = NULL
     
    511533        futex_down(&async_futex);
    512534       
    513         ht_link_t *hlp = hash_table_find(&conn_hash_table, &call->in_phone_hash);
    514        
    515         if (!hlp) {
     535        ht_link_t *link = hash_table_find(&conn_hash_table, &call->in_phone_hash);
     536        if (!link) {
    516537                futex_up(&async_futex);
    517538                return false;
    518539        }
    519540       
    520         connection_t *conn = hash_table_get_inst(hlp, connection_t, link);
     541        connection_t *conn = hash_table_get_inst(link, connection_t, link);
    521542       
    522543        msg_t *msg = malloc(sizeof(*msg));
     
    553574 *
    554575 * When a notification arrives, a fibril with this implementing function is
    555  * created. It calls interrupt_received() and does the final cleanup.
     576 * created. It calls the corresponding notification handler and does the final
     577 * cleanup.
    556578 *
    557579 * @param arg Message structure pointer.
     
    565587       
    566588        msg_t *msg = (msg_t *) arg;
    567         interrupt_received(msg->callid, &msg->call);
     589        async_notification_handler_t handler = NULL;
     590        void *data = NULL;
     591       
     592        futex_down(&async_futex);
     593       
     594        ht_link_t *link = hash_table_find(&notification_hash_table,
     595            &IPC_GET_IMETHOD(msg->call));
     596        if (link) {
     597                notification_t *notification =
     598                    hash_table_get_inst(link, notification_t, link);
     599                handler = notification->handler;
     600                data = notification->data;
     601        }
     602       
     603        futex_up(&async_futex);
     604       
     605        if (handler)
     606                handler(msg->callid, &msg->call, data);
    568607       
    569608        free(msg);
     
    571610}
    572611
    573 /** Process interrupt notification.
     612/** Process notification.
    574613 *
    575614 * A new fibril is created which would process the notification.
     
    598637       
    599638        fid_t fid = fibril_create_generic(notification_fibril, msg,
    600             interrupt_handler_stksz);
     639            notification_handler_stksz);
    601640        if (fid == 0) {
    602641                free(msg);
     
    609648        futex_up(&async_futex);
    610649        return true;
     650}
     651
     652/** Subscribe to IRQ notification.
     653 *
     654 * @param inr     IRQ number.
     655 * @param devno   Device number of the device generating inr.
     656 * @param handler Notification handler.
     657 * @param data    Notification handler client data.
     658 * @param ucode   Top-half pseudocode handler.
     659 *
     660 * @return Zero on success or a negative error code.
     661 *
     662 */
     663int async_irq_subscribe(int inr, int devno,
     664    async_notification_handler_t handler, void *data, const irq_code_t *ucode)
     665{
     666        notification_t *notification =
     667            (notification_t *) malloc(sizeof(notification_t));
     668        if (!notification)
     669                return ENOMEM;
     670       
     671        futex_down(&async_futex);
     672       
     673        sysarg_t imethod = notification_avail;
     674        notification_avail++;
     675       
     676        notification->imethod = imethod;
     677        notification->handler = handler;
     678        notification->data = data;
     679       
     680        hash_table_insert(&notification_hash_table, &notification->link);
     681       
     682        futex_up(&async_futex);
     683       
     684        return ipc_irq_subscribe(inr, devno, imethod, ucode);
     685}
     686
     687/** Unsubscribe from IRQ notification.
     688 *
     689 * @param inr     IRQ number.
     690 * @param devno   Device number of the device generating inr.
     691 *
     692 * @return Zero on success or a negative error code.
     693 *
     694 */
     695int async_irq_unsubscribe(int inr, int devno)
     696{
     697        // TODO: Remove entry from hash table
     698        //       to avoid memory leak
     699       
     700        return ipc_irq_unsubscribe(inr, devno);
     701}
     702
     703/** Subscribe to event notifications.
     704 *
     705 * @param evno    Event type to subscribe.
     706 * @param handler Notification handler.
     707 * @param data    Notification handler client data.
     708 *
     709 * @return Zero on success or a negative error code.
     710 *
     711 */
     712int async_event_subscribe(event_type_t evno,
     713    async_notification_handler_t handler, void *data)
     714{
     715        notification_t *notification =
     716            (notification_t *) malloc(sizeof(notification_t));
     717        if (!notification)
     718                return ENOMEM;
     719       
     720        futex_down(&async_futex);
     721       
     722        sysarg_t imethod = notification_avail;
     723        notification_avail++;
     724       
     725        notification->imethod = imethod;
     726        notification->handler = handler;
     727        notification->data = data;
     728       
     729        hash_table_insert(&notification_hash_table, &notification->link);
     730       
     731        futex_up(&async_futex);
     732       
     733        return ipc_event_subscribe(evno, imethod);
     734}
     735
     736/** Subscribe to task event notifications.
     737 *
     738 * @param evno    Event type to subscribe.
     739 * @param handler Notification handler.
     740 * @param data    Notification handler client data.
     741 *
     742 * @return Zero on success or a negative error code.
     743 *
     744 */
     745int async_event_task_subscribe(event_task_type_t evno,
     746    async_notification_handler_t handler, void *data)
     747{
     748        notification_t *notification =
     749            (notification_t *) malloc(sizeof(notification_t));
     750        if (!notification)
     751                return ENOMEM;
     752       
     753        futex_down(&async_futex);
     754       
     755        sysarg_t imethod = notification_avail;
     756        notification_avail++;
     757       
     758        notification->imethod = imethod;
     759        notification->handler = handler;
     760        notification->data = data;
     761       
     762        hash_table_insert(&notification_hash_table, &notification->link);
     763       
     764        futex_up(&async_futex);
     765       
     766        return ipc_event_task_subscribe(evno, imethod);
     767}
     768
     769/** Unmask event notifications.
     770 *
     771 * @param evno Event type to unmask.
     772 *
     773 * @return Value returned by the kernel.
     774 *
     775 */
     776int async_event_unmask(event_type_t evno)
     777{
     778        return ipc_event_unmask(evno);
     779}
     780
     781/** Unmask task event notifications.
     782 *
     783 * @param evno Event type to unmask.
     784 *
     785 * @return Value returned by the kernel.
     786 *
     787 */
     788int async_event_task_unmask(event_task_type_t evno)
     789{
     790        return ipc_event_task_unmask(evno);
    611791}
    612792
     
    702882
    703883        futex_down(&async_futex);
    704         ht_link_t *lnk = hash_table_find(&client_hash_table, &client_id);
    705         if (lnk) {
    706                 client = hash_table_get_inst(lnk, client_t, link);
     884        ht_link_t *link = hash_table_find(&client_hash_table, &client_id);
     885        if (link) {
     886                client = hash_table_get_inst(link, client_t, link);
    707887                atomic_inc(&client->refcnt);
    708888        } else if (create) {
     
    11061286       
    11071287        if (!hash_table_create(&conn_hash_table, 0, 0, &conn_hash_table_ops))
     1288                abort();
     1289       
     1290        if (!hash_table_create(&notification_hash_table, 0, 0,
     1291            &notification_hash_table_ops))
    11081292                abort();
    11091293       
  • uspace/lib/c/generic/bd.c

    r8db09e4 r15d0046  
    150150}
    151151
     152int bd_sync_cache(bd_t *bd, aoff64_t ba, size_t cnt)
     153{
     154        async_exch_t *exch = async_exchange_begin(bd->sess);
     155
     156        int rc = async_req_3_0(exch, BD_SYNC_CACHE, LOWER32(ba),
     157            UPPER32(ba), cnt);
     158        async_exchange_end(exch);
     159
     160        return rc;
     161}
     162
    152163int bd_get_block_size(bd_t *bd, size_t *rbsize)
    153164{
  • uspace/lib/c/generic/bd_srv.c

    r8db09e4 r15d0046  
    128128}
    129129
     130static void bd_sync_cache_srv(bd_srv_t *srv, ipc_callid_t callid,
     131    ipc_call_t *call)
     132{
     133        aoff64_t ba;
     134        size_t cnt;
     135        int rc;
     136
     137        ba = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
     138        cnt = IPC_GET_ARG3(*call);
     139
     140        if (srv->srvs->ops->sync_cache == NULL) {
     141                async_answer_0(callid, ENOTSUP);
     142                return;
     143        }
     144
     145        rc = srv->srvs->ops->sync_cache(srv, ba, cnt);
     146        async_answer_0(callid, rc);
     147}
     148
    130149static void bd_write_blocks_srv(bd_srv_t *srv, ipc_callid_t callid,
    131150    ipc_call_t *call)
     
    190209        bd_srv_t *srv;
    191210
    192         srv = calloc(1, sizeof(srv));
     211        srv = calloc(1, sizeof(bd_srv_t));
    193212        if (srv == NULL)
    194213                return NULL;
     
    244263                        bd_read_toc_srv(srv, callid, &call);
    245264                        break;
     265                case BD_SYNC_CACHE:
     266                        bd_sync_cache_srv(srv, callid, &call);
     267                        break;
    246268                case BD_WRITE_BLOCKS:
    247269                        bd_write_blocks_srv(srv, callid, &call);
  • uspace/lib/c/generic/ddi.c

    r8db09e4 r15d0046  
    7171 * @param flags Flags for the new address space area.
    7272 * @param virt  Virtual address of the starting page.
    73  *
    74  * @return EOK on success
    75  * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability
    76  * @return ENOENT if there is no task with specified ID
     73 *              If set to AS_AREA_ANY ((void *) -1), a suitable value
     74 *              is found by the kernel, otherwise the kernel tries to
     75 *              obey the desired value.
     76 *
     77 * @return EOK on success.
     78 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
    7779 * @return ENOMEM if there was some problem in creating
    7880 *         the address space area.
     
    8587}
    8688
     89/** Unmap a piece of physical memory to task.
     90 *
     91 * Caller of this function must have the CAP_MEM_MANAGER capability.
     92 *
     93 * @param virt Virtual address from the phys-mapped region.
     94 *
     95 * @return EOK on success.
     96 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     97 *
     98 */
     99int physmem_unmap(void *virt)
     100{
     101        return __SYSCALL1(SYS_PHYSMEM_UNMAP, (sysarg_t) virt);
     102}
     103
     104/** Lock a piece physical memory for DMA transfers.
     105 *
     106 * The mapping of the specified virtual memory address
     107 * to physical memory address is locked in order to
     108 * make it safe for DMA transferts.
     109 *
     110 * Caller of this function must have the CAP_MEM_MANAGER capability.
     111 *
     112 * @param virt      Virtual address of the memory to be locked.
     113 * @param size      Number of bytes to lock.
     114 * @param map_flags Desired virtual memory area flags.
     115 * @param flags     Flags for the physical memory address.
     116 * @param phys      Locked physical memory address.
     117 *
     118 * @return EOK on success.
     119 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     120 * @return ENOMEM if there was some problem in creating
     121 *         the address space area.
     122 *
     123 */
    87124int dmamem_map(void *virt, size_t size, unsigned int map_flags,
    88125    unsigned int flags, uintptr_t *phys)
     
    93130}
    94131
     132/** Map a piece of physical memory suitable for DMA transfers.
     133 *
     134 * Caller of this function must have the CAP_MEM_MANAGER capability.
     135 *
     136 * @param size       Number of bytes to map.
     137 * @param constraint Bit mask defining the contraint on the physical
     138 *                   address to be mapped.
     139 * @param map_flags  Desired virtual memory area flags.
     140 * @param flags      Flags for the physical memory address.
     141 * @param virt       Virtual address of the starting page.
     142 *                   If set to AS_AREA_ANY ((void *) -1), a suitable value
     143 *                   is found by the kernel, otherwise the kernel tries to
     144 *                   obey the desired value.
     145 *
     146 * @return EOK on success.
     147 * @return EPERM if the caller lacks the CAP_MEM_MANAGER capability.
     148 * @return ENOMEM if there was some problem in creating
     149 *         the address space area.
     150 *
     151 */
    95152int dmamem_map_anonymous(size_t size, uintptr_t constraint,
    96153    unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt)
     
    137194       
    138195        return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
     196}
     197
     198/** Disable I/O space range to task.
     199 *
     200 * Caller of this function must have the IO_MEM_MANAGER capability.
     201 *
     202 * @param id     Task ID.
     203 * @param ioaddr Starting address of the I/O range.
     204 * @param size   Size of the range.
     205 *
     206 * @return EOK on success
     207 * @return EPERM if the caller lacks the CAP_IO_MANAGER capability
     208 * @return ENOENT if there is no task with specified ID
     209 *
     210 */
     211static int iospace_disable(task_id_t id, void *ioaddr, size_t size)
     212{
     213        const ddi_ioarg_t arg = {
     214                .task_id = id,
     215                .ioaddr = ioaddr,
     216                .size = size
     217        };
     218       
     219        return __SYSCALL1(SYS_IOSPACE_DISABLE, (sysarg_t) &arg);
    139220}
    140221
     
    221302        size_t pages = SIZE2PAGES(offset + size);
    222303       
    223         void *virt_page;
     304        void *virt_page = AS_AREA_ANY;
    224305        int rc = physmem_map(phys_frame, pages,
    225306            AS_AREA_READ | AS_AREA_WRITE, &virt_page);
     
    231312}
    232313
     314/** Disable PIO for specified I/O range.
     315 *
     316 * @param virt     I/O start address.
     317 * @param size     Size of the I/O region.
     318 *
     319 * @return EOK on success.
     320 * @return Negative error code on failure.
     321 *
     322 */
     323int pio_disable(void *virt, size_t size)
     324{
     325#ifdef IO_SPACE_BOUNDARY
     326        if (virt < IO_SPACE_BOUNDARY)
     327                return iospace_disable(task_get_id(), virt, size);
     328#else
     329        (void) iospace_disable;
     330#endif
     331        return physmem_unmap(virt);
     332}
     333
    233334void pio_write_8(ioport8_t *reg, uint8_t val)
    234335{
     
    270371}
    271372
    272 /** Register IRQ notification.
    273  *
    274  * @param inr    IRQ number.
    275  * @param devno  Device number of the device generating inr.
    276  * @param method Use this method for notifying me.
    277  * @param ucode  Top-half pseudocode handler.
    278  *
    279  * @return Value returned by the kernel.
    280  *
    281  */
    282 int irq_register(int inr, int devno, int method, const irq_code_t *ucode)
    283 {
    284         return __SYSCALL4(SYS_IRQ_REGISTER, inr, devno, method,
    285             (sysarg_t) ucode);
    286 }
    287 
    288 /** Unregister IRQ notification.
    289  *
    290  * @param inr   IRQ number.
    291  * @param devno Device number of the device generating inr.
    292  *
    293  * @return Value returned by the kernel.
    294  *
    295  */
    296 int irq_unregister(int inr, int devno)
    297 {
    298         return __SYSCALL2(SYS_IRQ_UNREGISTER, inr, devno);
    299 }
    300 
    301373/** @}
    302374 */
  • uspace/lib/c/generic/device/clock_dev.c

    r8db09e4 r15d0046  
    2727 */
    2828
    29  /** @addtogroup libc
     29/** @addtogroup libc
    3030 * @{
    3131 */
  • uspace/lib/c/generic/device/led_dev.c

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2011 Jan Vesely
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvmouse
     28
     29/** @addtogroup libc
    2930 * @{
    3031 */
    3132/** @file
    32  * @brief ps/2 mouse driver.
    3333 */
    3434
    35 #ifndef _CHARDEV_H_
    36 #define _CHARDEV_H_
     35#include <errno.h>
     36#include <async.h>
     37#include <io/pixel.h>
     38#include <ipc/dev_iface.h>
     39#include <device/led_dev.h>
    3740
    38 #include <libarch/types.h>
    39 #include <async.h>
     41int led_dev_color_set(async_sess_t *sess, pixel_t pixel)
     42{
     43        async_exch_t *exch = async_exchange_begin(sess);
     44       
     45        aid_t req = async_send_2(exch, DEV_IFACE_ID(LED_DEV_IFACE),
     46            LED_DEV_COLOR_SET, (sysarg_t) pixel, NULL);
     47       
     48        async_exchange_end(exch);
     49       
     50        sysarg_t rc;
     51        async_wait_for(req, &rc);
     52       
     53        return (int) rc;
     54}
    4055
    41 ssize_t chardev_read(async_exch_t *, void *, size_t);
    42 ssize_t chardev_write(async_exch_t *, const void *, size_t);
    43 
    44 #endif
    45 /**
    46  * @}
     56/** @}
    4757 */
  • uspace/lib/c/generic/event.c

    r8db09e4 r15d0046  
    3838
    3939#include <libc.h>
    40 #include <event.h>
     40#include <ipc/event.h>
    4141
    42 /** Subscribe event notifications.
     42/** Subscribe to event notifications.
    4343 *
    4444 * @param evno    Event type to subscribe.
     
    4848 *
    4949 */
    50 int event_subscribe(event_type_t evno, sysarg_t imethod)
     50int ipc_event_subscribe(event_type_t evno, sysarg_t imethod)
    5151{
    52         return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
     52        return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno,
    5353            (sysarg_t) imethod);
    5454}
    5555
    56 int event_task_subscribe(event_task_type_t evno, sysarg_t imethod)
     56/** Subscribe to task event notifications.
     57 *
     58 * @param evno    Event type to subscribe.
     59 * @param imethod Use this interface and method for notifying me.
     60 *
     61 * @return Value returned by the kernel.
     62 *
     63 */
     64int ipc_event_task_subscribe(event_task_type_t evno, sysarg_t imethod)
    5765{
    58         return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
     66        return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno,
    5967            (sysarg_t) imethod);
     68}
     69
     70/** Unsubscribe from event notifications.
     71 *
     72 * @param evno    Event type to unsubscribe.
     73 *
     74 * @return Value returned by the kernel.
     75 *
     76 */
     77int ipc_event_unsubscribe(event_type_t evno)
     78{
     79        return __SYSCALL1(SYS_IPC_EVENT_UNSUBSCRIBE, (sysarg_t) evno);
     80}
     81
     82/** Unsubscribe from task event notifications.
     83 *
     84 * @param evno    Event type to unsubscribe.
     85 *
     86 * @return Value returned by the kernel.
     87 *
     88 */
     89int ipc_event_task_unsubscribe(event_task_type_t evno)
     90{
     91        return __SYSCALL1(SYS_IPC_EVENT_UNSUBSCRIBE, (sysarg_t) evno);
    6092}
    6193
     
    6799 *
    68100 */
    69 int event_unmask(event_type_t evno)
     101int ipc_event_unmask(event_type_t evno)
    70102{
    71         return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
     103        return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno);
    72104}
    73105
    74 int event_task_unmask(event_task_type_t evno)
     106/** Unmask task event notifications.
     107 *
     108 * @param evno Event type to unmask.
     109 *
     110 * @return Value returned by the kernel.
     111 *
     112 */
     113int ipc_event_task_unmask(event_task_type_t evno)
    75114{
    76         return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
     115        return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno);
    77116}
    78117
  • uspace/lib/c/generic/fibril.c

    r8db09e4 r15d0046  
    5959static LIST_INITIALIZE(serialized_list);
    6060static LIST_INITIALIZE(manager_list);
     61static LIST_INITIALIZE(fibril_list);
    6162
    6263/** Number of threads that are executing a manager fibril. */
     
    116117       
    117118        fibril->waits_for = NULL;
     119        list_append(&fibril->all_link, &fibril_list);
    118120       
    119121        return fibril;
     
    122124void fibril_teardown(fibril_t *fibril)
    123125{
     126        list_remove(&fibril->all_link);
    124127        tls_free(fibril->tcb);
    125128        free(fibril);
  • uspace/lib/c/generic/fibril_synch.c

    r8db09e4 r15d0046  
    448448        int rc;
    449449
    450         fibril_mutex_lock(&timer->lock);
    451 
    452         while (true) {
    453                 while (timer->state != fts_active &&
    454                     timer->state != fts_cleanup) {
    455 
    456                         if (timer->state == fts_cleanup)
    457                                 break;
    458 
    459                         fibril_condvar_wait(&timer->cv, &timer->lock);
     450        fibril_mutex_lock(timer->lockp);
     451
     452        while (timer->state != fts_cleanup) {
     453                switch (timer->state) {
     454                case fts_not_set:
     455                case fts_fired:
     456                        fibril_condvar_wait(&timer->cv, timer->lockp);
     457                        break;
     458                case fts_active:
     459                        rc = fibril_condvar_wait_timeout(&timer->cv,
     460                            timer->lockp, timer->delay);
     461                        if (rc == ETIMEOUT && timer->state == fts_active) {
     462                                timer->state = fts_fired;
     463                                timer->handler_running = true;
     464                                fibril_mutex_unlock(timer->lockp);
     465                                timer->fun(timer->arg);
     466                                fibril_mutex_lock(timer->lockp);
     467                                timer->handler_running = false;
     468                        }
     469                        break;
     470                case fts_cleanup:
     471                case fts_clean:
     472                        assert(false);
     473                        break;
    460474                }
    461 
    462                 if (timer->state == fts_cleanup)
    463                         break;
    464 
    465                 rc = fibril_condvar_wait_timeout(&timer->cv, &timer->lock,
    466                     timer->delay);
    467                 if (rc == ETIMEOUT) {
    468                         timer->state = fts_fired;
    469                         fibril_mutex_unlock(&timer->lock);
    470                         timer->fun(timer->arg);
    471                         fibril_mutex_lock(&timer->lock);
    472                 }
    473         }
    474 
    475         fibril_mutex_unlock(&timer->lock);
     475        }
     476
     477        /* Acknowledge timer fibril has finished cleanup. */
     478        timer->state = fts_clean;
     479        fibril_mutex_unlock(timer->lockp);
     480        free(timer);
     481
    476482        return 0;
    477483}
     
    481487 * @return              New timer on success, @c NULL if out of memory.
    482488 */
    483 fibril_timer_t *fibril_timer_create(void)
     489fibril_timer_t *fibril_timer_create(fibril_mutex_t *lock)
    484490{
    485491        fid_t fid;
     
    501507        timer->fibril = fid;
    502508        timer->state = fts_not_set;
     509        timer->lockp = (lock != NULL) ? lock : &timer->lock;
    503510
    504511        fibril_add_ready(fid);
    505 
    506512        return timer;
    507513}
     
    513519void fibril_timer_destroy(fibril_timer_t *timer)
    514520{
    515         fibril_mutex_lock(&timer->lock);
    516         assert(timer->state != fts_active);
     521        fibril_mutex_lock(timer->lockp);
     522        assert(timer->state == fts_not_set || timer->state == fts_fired);
     523
     524        /* Request timer fibril to terminate. */
    517525        timer->state = fts_cleanup;
    518526        fibril_condvar_broadcast(&timer->cv);
    519         fibril_mutex_unlock(&timer->lock);
     527        fibril_mutex_unlock(timer->lockp);
    520528}
    521529
     
    533541    fibril_timer_fun_t fun, void *arg)
    534542{
    535         fibril_mutex_lock(&timer->lock);
     543        fibril_mutex_lock(timer->lockp);
     544        fibril_timer_set_locked(timer, delay, fun, arg);
     545        fibril_mutex_unlock(timer->lockp);
     546}
     547
     548/** Set locked timer.
     549 *
     550 * Set timer to execute a callback function after the specified
     551 * interval. Must be called when the timer is locked.
     552 *
     553 * @param timer         Timer
     554 * @param delay         Delay in microseconds
     555 * @param fun           Callback function
     556 * @param arg           Argument for @a fun
     557 */
     558void fibril_timer_set_locked(fibril_timer_t *timer, suseconds_t delay,
     559    fibril_timer_fun_t fun, void *arg)
     560{
     561        assert(fibril_mutex_is_locked(timer->lockp));
     562        assert(timer->state == fts_not_set || timer->state == fts_fired);
    536563        timer->state = fts_active;
    537564        timer->delay = delay;
     
    539566        timer->arg = arg;
    540567        fibril_condvar_broadcast(&timer->cv);
    541         fibril_mutex_unlock(&timer->lock);
    542568}
    543569
     
    557583        fibril_timer_state_t old_state;
    558584
    559         fibril_mutex_lock(&timer->lock);
     585        fibril_mutex_lock(timer->lockp);
     586        old_state = fibril_timer_clear_locked(timer);
     587        fibril_mutex_unlock(timer->lockp);
     588
     589        return old_state;
     590}
     591
     592/** Clear locked timer.
     593 *
     594 * Clears (cancels) timer and returns last state of the timer.
     595 * This can be one of:
     596 *    - fts_not_set     If the timer has not been set or has been cleared
     597 *    - fts_active      Timer was set but did not fire
     598 *    - fts_fired       Timer fired
     599 * Must be called when the timer is locked.
     600 *
     601 * @param timer         Timer
     602 * @return              Last timer state
     603 */
     604fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *timer)
     605{
     606        fibril_timer_state_t old_state;
     607
     608        assert(fibril_mutex_is_locked(timer->lockp));
     609
     610        while (timer->handler_running)
     611                fibril_condvar_wait(&timer->cv, timer->lockp);
     612
    560613        old_state = timer->state;
    561614        timer->state = fts_not_set;
     
    565618        timer->arg = NULL;
    566619        fibril_condvar_broadcast(&timer->cv);
    567         fibril_mutex_unlock(&timer->lock);
    568620
    569621        return old_state;
  • uspace/lib/c/generic/inet.c

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2012 Jiri Svoboda
     2 * Copyright (c) 2013 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3434#include <ipc/services.h>
    3535#include <loc.h>
     36#include <stdlib.h>
    3637
    3738static void inet_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    224225       
    225226        rc = inet_ev_ops->recv(&dgram);
     227        free(dgram.data);
    226228        async_answer_0(iid, rc);
    227229}
  • uspace/lib/c/generic/io/asprintf.c

    r8db09e4 r15d0046  
    7676 *             the newly allocated string.
    7777 * @fmt        Format string.
     78 * @args       Variable argument list
     79 *
     80 * @return Number of characters printed or a negative error code.
     81 *
     82 */
     83int vasprintf(char **strp, const char *fmt, va_list args)
     84{
     85        va_list args2;
     86        va_copy(args2, args);
     87        int ret = vprintf_size(fmt, args2);
     88        va_end(args2);
     89       
     90        if (ret > 0) {
     91                *strp = malloc(STR_BOUNDS(ret) + 1);
     92                if (*strp == NULL)
     93                        return -1;
     94               
     95                vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
     96        }
     97       
     98        return ret;
     99}
     100
     101/** Allocate and print to string.
     102 *
     103 * @param strp Address of the pointer where to store the address of
     104 *             the newly allocated string.
     105 * @fmt        Format string.
    78106 *
    79107 * @return Number of characters printed or a negative error code.
     
    84112        va_list args;
    85113        va_start(args, fmt);
    86         int ret = vprintf_size(fmt, args);
     114        int ret = vasprintf(strp, fmt, args);
    87115        va_end(args);
    88        
    89         if (ret > 0) {
    90                 *strp = malloc(STR_BOUNDS(ret) + 1);
    91                 if (*strp == NULL)
    92                         return -1;
    93                
    94                 va_start(args, fmt);
    95                 vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
    96                 va_end(args);
    97         }
    98116       
    99117        return ret;
  • uspace/lib/c/generic/io/chardev.c

    r8db09e4 r15d0046  
    2929#include <errno.h>
    3030#include <mem.h>
    31 #include <ipc/dev_iface.h>
    32 #include <ddf/log.h>
    33 
    34 #include "chardev.h"
    35 
    36 // TODO make this shared
    37 enum {
    38         IPC_CHAR_READ = DEV_FIRST_CUSTOM_METHOD,
    39         IPC_CHAR_WRITE,
    40 };
     31#include <io/chardev.h>
     32#include <ipc/chardev.h>
    4133
    4234ssize_t chardev_read(async_exch_t *exch, void *data, size_t size)
     
    4840
    4941        sysarg_t message[4] = { 0 };
    50         const ssize_t ret = async_req_1_4(exch, IPC_CHAR_READ, size,
     42        const ssize_t ret = async_req_1_4(exch, CHARDEV_READ, size,
    5143            &message[0], &message[1], &message[2], &message[3]);
    5244        if (ret > 0 && (size_t)ret <= size)
     
    6456        sysarg_t message[3] = { 0 };
    6557        memcpy(message, data, size);
    66         return async_req_4_0(exch, IPC_CHAR_WRITE, size,
     58        return async_req_4_0(exch, CHARDEV_WRITE, size,
    6759            message[0], message[1], message[2]);
    6860}
  • uspace/lib/c/generic/io/console.c

    r8db09e4 r15d0046  
    7575bool console_kcon(void)
    7676{
    77         return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE);
     77        return __SYSCALL0(SYS_DEBUG_CONSOLE);
    7878}
    7979
  • uspace/lib/c/generic/io/input.c

    r8db09e4 r15d0046  
    8080}
    8181
    82 int input_yield(input_t *input)
     82int input_activate(input_t *input)
    8383{
    8484        async_exch_t *exch = async_exchange_begin(input->sess);
    85 
    86         int rc = async_req_0_0(exch, INPUT_YIELD);
     85        int rc = async_req_0_0(exch, INPUT_ACTIVATE);
    8786        async_exchange_end(exch);
    88 
     87       
    8988        return rc;
    9089}
    9190
    92 int input_reclaim(input_t *input)
    93 {
    94         async_exch_t *exch = async_exchange_begin(input->sess);
    95 
    96         int rc = async_req_0_0(exch, INPUT_RECLAIM);
    97         async_exchange_end(exch);
    98 
    99         return rc;
     91static void input_ev_active(input_t *input, ipc_callid_t callid,
     92    ipc_call_t *call)
     93{
     94        int rc = input->ev_ops->active(input);
     95        async_answer_0(callid, rc);
     96}
     97
     98static void input_ev_deactive(input_t *input, ipc_callid_t callid,
     99    ipc_call_t *call)
     100{
     101        int rc = input->ev_ops->deactive(input);
     102        async_answer_0(callid, rc);
    100103}
    101104
     
    178181
    179182                switch (IPC_GET_IMETHOD(call)) {
     183                case INPUT_EVENT_ACTIVE:
     184                        input_ev_active(input, callid, &call);
     185                        break;
     186                case INPUT_EVENT_DEACTIVE:
     187                        input_ev_deactive(input, callid, &call);
     188                        break;
    180189                case INPUT_EVENT_KEY:
    181190                        input_ev_key(input, callid, &call);
  • uspace/lib/c/generic/iplink.c

    r8db09e4 r15d0046  
    171171}
    172172
     173int iplink_set_mac48(iplink_t *iplink, addr48_t mac)
     174{
     175        async_exch_t *exch = async_exchange_begin(iplink->sess);
     176       
     177        ipc_call_t answer;
     178        aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
     179       
     180        int rc = async_data_read_start(exch, mac, sizeof(addr48_t));
     181       
     182        loc_exchange_end(exch);
     183       
     184        if (rc != EOK) {
     185                async_forget(req);
     186                return rc;
     187        }
     188       
     189        sysarg_t retval;
     190        async_wait_for(req, &retval);
     191       
     192        return (int) retval;
     193}
     194
     195
    173196int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr)
    174197{
     
    230253        free(sdu.data);
    231254        async_answer_0(iid, rc);
     255}
     256
     257static void iplink_ev_change_addr(iplink_t *iplink, ipc_callid_t iid,
     258    ipc_call_t *icall)
     259{
     260        addr48_t *addr;
     261        size_t size;
     262       
     263        int rc = async_data_write_accept((void **)&addr, false,
     264            sizeof(addr48_t), sizeof(addr48_t), 0, &size);
     265        if (rc != EOK) {
     266                async_answer_0(iid, rc);
     267                return;
     268        }
     269
     270        rc = iplink->ev_ops->change_addr(iplink, *addr);
     271        free(addr);
     272        async_answer_0(iid, EOK);
    232273}
    233274
     
    249290                        iplink_ev_recv(iplink, callid, &call);
    250291                        break;
     292                case IPLINK_EV_CHANGE_ADDR:
     293                        iplink_ev_change_addr(iplink, callid, &call);
    251294                default:
    252295                        async_answer_0(callid, ENOTSUP);
  • uspace/lib/c/generic/iplink_srv.c

    r8db09e4 r15d0046  
    8181}
    8282
     83static void iplink_set_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid,
     84    ipc_call_t *icall)
     85{
     86        int rc;
     87        size_t size;
     88        addr48_t mac;
     89        ipc_callid_t callid;
     90
     91        rc = async_data_write_receive(&callid, &size);
     92        if (rc != EOK) {
     93                async_answer_0(callid, (sysarg_t) rc);
     94                async_answer_0(iid, (sysarg_t) rc);
     95        }
     96
     97        rc = srv->ops->set_mac48(srv, &mac);
     98        if (rc != EOK) {
     99                async_answer_0(iid, rc);
     100                return;
     101        }
     102       
     103        rc = async_data_read_finalize(callid, &mac, sizeof(addr48_t));
     104        if (rc != EOK)
     105                async_answer_0(callid, rc);
     106       
     107        async_answer_0(iid, (sysarg_t) rc);
     108}
     109
    83110static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid,
    84111    ipc_call_t *icall)
     
    252279                        iplink_get_mac48_srv(srv, callid, &call);
    253280                        break;
     281                case IPLINK_SET_MAC48:
     282                        iplink_set_mac48_srv(srv, callid, &call);
     283                        break;
    254284                case IPLINK_SEND:
    255285                        iplink_send_srv(srv, callid, &call);
     
    300330}
    301331
     332int iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr)
     333{
     334        if (srv->client_sess == NULL)
     335                return EIO;
     336       
     337        async_exch_t *exch = async_exchange_begin(srv->client_sess);
     338       
     339        ipc_call_t answer;
     340        aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer);
     341       
     342        int rc = async_data_write_start(exch, addr, sizeof(addr48_t));
     343        async_exchange_end(exch);
     344       
     345        if (rc != EOK) {
     346                async_forget(req);
     347                return rc;
     348        }
     349       
     350        sysarg_t retval;
     351        async_wait_for(req, &retval);
     352        if (retval != EOK)
     353                return retval;
     354       
     355        return EOK;
     356}
     357
    302358/** @}
    303359 */
  • uspace/lib/c/generic/irq.c

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2005 Jakub Jermar
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mips64mm
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include <arch/mm/as.h>
    36 #include <genarch/mm/as_ht.h>
    37 #include <genarch/mm/page_ht.h>
    38 #include <genarch/mm/asid_fifo.h>
    39 #include <arch/mm/tlb.h>
    40 #include <mm/tlb.h>
    41 #include <mm/as.h>
    42 #include <arch/cp0.h>
     35#include <ipc/irq.h>
     36#include <libc.h>
    4337
    44 /** Architecture dependent address space init. */
    45 void as_arch_init(void)
     38/** Subscribe to IRQ notification.
     39 *
     40 * @param inr    IRQ number.
     41 * @param devno  Device number of the device generating inr.
     42 * @param method Use this method for notifying me.
     43 * @param ucode  Top-half pseudocode handler.
     44 *
     45 * @return Value returned by the kernel.
     46 *
     47 */
     48int ipc_irq_subscribe(int inr, int devno, sysarg_t method,
     49    const irq_code_t *ucode)
    4650{
    47         as_operations = &as_ht_operations;
    48         asid_fifo_init();
     51        return __SYSCALL4(SYS_IPC_IRQ_SUBSCRIBE, inr, devno, method,
     52            (sysarg_t) ucode);
    4953}
    5054
    51 /** Install address space.
     55/** Unsubscribe from IRQ notification.
    5256 *
    53  * Install ASID.
     57 * @param inr   IRQ number.
     58 * @param devno Device number of the device generating inr.
    5459 *
    55  * @param as Address space structure.
     60 * @return Value returned by the kernel.
    5661 *
    5762 */
    58 void as_install_arch(as_t *as)
     63int ipc_irq_unsubscribe(int inr, int devno)
    5964{
    60         /*
    61          * Install ASID.
    62          */
    63         entry_hi_t hi;
    64         hi.value = cp0_entry_hi_read();
    65         hi.asid = as->asid;
    66         cp0_entry_hi_write(hi.value);
     65        return __SYSCALL2(SYS_IPC_IRQ_UNSUBSCRIBE, inr, devno);
    6766}
    6867
  • uspace/lib/c/generic/stacktrace.c

    r8db09e4 r15d0046  
    4242static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
    4343
    44 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
     44static stacktrace_ops_t basic_ops = {
     45        .read_uintptr = stacktrace_read_uintptr
     46};
     47
     48void stacktrace_print_generic(stacktrace_ops_t *ops, void *arg, uintptr_t fp,
     49    uintptr_t pc)
    4550{
    4651        stacktrace_t st;
    4752        uintptr_t nfp;
     53        int rc;
    4854
    49         st.op_arg = NULL;
    50         st.read_uintptr = stacktrace_read_uintptr;
     55        st.op_arg = arg;
     56        st.ops = ops;
    5157
    5258        while (stacktrace_fp_valid(&st, fp)) {
    5359                printf("%p: %p()\n", (void *) fp, (void *) pc);
    54                 (void) stacktrace_ra_get(&st, fp, &pc);
    55                 (void) stacktrace_fp_prev(&st, fp, &nfp);
     60                rc =  stacktrace_ra_get(&st, fp, &pc);
     61                if (rc != EOK)
     62                        break;
     63                rc = stacktrace_fp_prev(&st, fp, &nfp);
     64                if (rc != EOK)
     65                        break;
    5666                fp = nfp;
    5767        }
     68}
     69
     70void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
     71{
     72        stacktrace_print_generic(&basic_ops, NULL, fp, pc);
    5873}
    5974
  • uspace/lib/c/generic/str.c

    r8db09e4 r15d0046  
    13601360}
    13611361
    1362 char *strtok(char *s, const char *delim)
    1363 {
    1364         static char *next;
    1365 
    1366         return strtok_r(s, delim, &next);
    1367 }
    1368 
    1369 char *strtok_r(char *s, const char *delim, char **next)
     1362/** Split string by delimiters.
     1363 *
     1364 * @param s             String to be tokenized. May not be NULL.
     1365 * @param delim         String with the delimiters.
     1366 * @param next          Variable which will receive the pointer to the
     1367 *                      continuation of the string following the first
     1368 *                      occurrence of any of the delimiter characters.
     1369 *                      May be NULL.
     1370 * @return              Pointer to the prefix of @a s before the first
     1371 *                      delimiter character. NULL if no such prefix
     1372 *                      exists.
     1373 */
     1374char *str_tok(char *s, const char *delim, char **next)
    13701375{
    13711376        char *start, *end;
    13721377
    1373         if (s == NULL)
    1374                 s = *next;
     1378        if (!s)
     1379                return NULL;
     1380       
     1381        size_t len = str_size(s);
     1382        size_t cur;
     1383        size_t tmp;
     1384        wchar_t ch;
    13751385
    13761386        /* Skip over leading delimiters. */
    1377         while (*s && (str_chr(delim, *s) != NULL)) ++s;
    1378         start = s;
     1387        for (tmp = cur = 0;
     1388            (ch = str_decode(s, &tmp, len)) && str_chr(delim, ch); /**/)
     1389                cur = tmp;
     1390        start = &s[cur];
    13791391
    13801392        /* Skip over token characters. */
    1381         while (*s && (str_chr(delim, *s) == NULL)) ++s;
    1382         end = s;
    1383         *next = (*s ? s + 1 : s);
    1384 
    1385         if (start == end) {
     1393        for (tmp = cur;
     1394            (ch = str_decode(s, &tmp, len)) && !str_chr(delim, ch); /**/)
     1395                cur = tmp;
     1396        end = &s[cur];
     1397        if (next)
     1398                *next = (ch ? &s[tmp] : &s[cur]);
     1399
     1400        if (start == end)
    13861401                return NULL;    /* No more tokens. */
    1387         }
    13881402
    13891403        /* Overwrite delimiter with NULL terminator. */
  • uspace/lib/c/generic/task.c

    r8db09e4 r15d0046  
    22 * Copyright (c) 2006 Jakub Jermar
    33 * Copyright (c) 2008 Jiri Svoboda
     4 * Copyright (c) 2014 Martin Sucha
    45 * All rights reserved.
    56 *
     
    9495 *
    9596 * @param id   If not NULL, the ID of the task is stored here on success.
     97 * @param wait If not NULL, setup waiting for task's return value and store
     98 *             the information necessary for waiting here on success.
    9699 * @param path Pathname of the binary to execute.
    97100 * @param argv Command-line arguments.
     
    100103 *
    101104 */
    102 int task_spawnv(task_id_t *id, const char *path, const char *const args[])
     105int task_spawnv(task_id_t *id, task_wait_t *wait, const char *path,
     106    const char *const args[])
    103107{
    104108        /* Send default files */
     
    125129        files[3] = NULL;
    126130       
    127         return task_spawnvf(id, path, args, files);
     131        return task_spawnvf(id, wait, path, args, files);
    128132}
    129133
     
    135139 *
    136140 * @param id    If not NULL, the ID of the task is stored here on success.
     141 * @param wait  If not NULL, setup waiting for task's return value and store
     142 *              the information necessary for waiting here on success.
    137143 * @param path  Pathname of the binary to execute.
    138144 * @param argv  Command-line arguments.
     
    142148 *
    143149 */
    144 int task_spawnvf(task_id_t *id, const char *path, const char *const args[],
    145     int *const files[])
     150int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path,
     151    const char *const args[], int *const files[])
    146152{
    147153        /* Connect to a program loader. */
     
    150156                return EREFUSED;
    151157       
     158        bool wait_initialized = false;
     159       
    152160        /* Get task ID. */
    153161        task_id_t task_id;
     
    181189                goto error;
    182190       
     191        /* Setup waiting for return value if needed */
     192        if (wait) {
     193                rc = task_setup_wait(task_id, wait);
     194                if (rc != EOK)
     195                        goto error;
     196                wait_initialized = true;
     197        }
     198       
    183199        /* Run it. */
    184200        rc = loader_run(ldr);
     
    193209       
    194210error:
     211        if (wait_initialized)
     212                task_cancel_wait(wait);
     213       
    195214        /* Error exit */
    196215        loader_abort(ldr);
     
    204223 *
    205224 * @param id   If not NULL, the ID of the task is stored here on success.
     225 * @param wait If not NULL, setup waiting for task's return value and store
     226 *             the information necessary for waiting here on success.
    206227 * @param path Pathname of the binary to execute.
    207228 * @param cnt  Number of arguments.
     
    211232 *
    212233 */
    213 int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap)
     234int task_spawn(task_id_t *task_id, task_wait_t *wait, const char *path,
     235    int cnt, va_list ap)
    214236{
    215237        /* Allocate argument list. */
     
    227249       
    228250        /* Spawn task. */
    229         int rc = task_spawnv(task_id, path, arglist);
     251        int rc = task_spawnv(task_id, wait, path, arglist);
    230252       
    231253        /* Free argument list. */
     
    240262 *
    241263 * @param id   If not NULL, the ID of the task is stored here on success.
     264 * @param wait If not NULL, setup waiting for task's return value and store
     265 *             the information necessary for waiting here on success.
    242266 * @param path Pathname of the binary to execute.
    243267 * @param ...  Command-line arguments.
     
    246270 *
    247271 */
    248 int task_spawnl(task_id_t *task_id, const char *path, ...)
     272int task_spawnl(task_id_t *task_id, task_wait_t *wait, const char *path, ...)
    249273{
    250274        /* Count the number of arguments. */
     
    262286       
    263287        va_start(ap, path);
    264         int rc = task_spawn(task_id, path, cnt, ap);
     288        int rc = task_spawn(task_id, wait, path, cnt, ap);
    265289        va_end(ap);
    266290       
     
    268292}
    269293
    270 int task_wait(task_id_t id, task_exit_t *texit, int *retval)
     294/** Setup waiting for a task.
     295 *
     296 * If the task finishes after this call succeeds, it is guaranteed that
     297 * task_wait(wait, &texit, &retval) will return correct return value for
     298 * the task.
     299 *
     300 * @param id   ID of the task to setup waiting for.
     301 * @param wait Information necessary for the later task_wait call is stored here.
     302 *
     303 * @return EOK on success, else error code.
     304 */
     305int task_setup_wait(task_id_t id, task_wait_t *wait)
     306{
     307        async_exch_t *exch = async_exchange_begin(session_ns);
     308        wait->aid = async_send_2(exch, NS_TASK_WAIT, LOWER32(id), UPPER32(id),
     309            &wait->result);
     310        async_exchange_end(exch);
     311
     312        return EOK;
     313}
     314
     315/** Cancel waiting for a task.
     316 *
     317 * This can be called *instead of* task_wait if the caller is not interested
     318 * in waiting for the task anymore.
     319 *
     320 * This function cannot be called if the task_wait was already called.
     321 *
     322 * @param wait task_wait_t previously initialized by task_setup_wait.
     323 */
     324void task_cancel_wait(task_wait_t *wait) {
     325        async_forget(wait->aid);
     326}
     327
     328/** Wait for a task to finish.
     329 *
     330 * This function returns correct values even if the task finished in
     331 * between task_setup_wait and this task_wait call.
     332 *
     333 * This function cannot be called more than once with the same task_wait_t
     334 * (it can be reused, but must be reinitialized with task_setup_wait first)
     335 *
     336 * @param wait   task_wait_t previously initialized by task_setup_wait.
     337 * @param texit  Store type of task exit here.
     338 * @param retval Store return value of the task here.
     339 *
     340 * @return EOK on success, else error code.
     341 */
     342int task_wait(task_wait_t *wait, task_exit_t *texit, int *retval)
    271343{
    272344        assert(texit);
    273345        assert(retval);
    274        
    275         async_exch_t *exch = async_exchange_begin(session_ns);
    276         sysarg_t te, rv;
    277         int rc = (int) async_req_2_2(exch, NS_TASK_WAIT, LOWER32(id),
    278             UPPER32(id), &te, &rv);
    279         async_exchange_end(exch);
    280        
    281         *texit = te;
    282         *retval = rv;
    283        
    284         return rc;
     346
     347        sysarg_t rc;
     348        async_wait_for(wait->aid, &rc);
     349
     350        if (rc == EOK) {
     351                *texit = IPC_GET_ARG1(wait->result);
     352                *retval = IPC_GET_ARG2(wait->result);
     353        }
     354
     355        return rc;
     356}
     357
     358/** Wait for a task to finish by its id.
     359 *
     360 * Note that this will fail with ENOENT if the task id is not registered in ns
     361 * (e.g. if the task finished). If you are spawning a task and need to wait
     362 * for its completion, use wait parameter of the task_spawn* functions instead
     363 * to prevent a race where the task exits before you may have a chance to wait
     364 * wait for it.
     365 *
     366 * @param id ID of the task to wait for.
     367 * @param texit  Store type of task exit here.
     368 * @param retval Store return value of the task here.
     369 *
     370 * @return EOK on success, else error code.
     371 */
     372int task_wait_task_id(task_id_t id, task_exit_t *texit, int *retval)
     373{
     374        task_wait_t wait;
     375        int rc = task_setup_wait(id, &wait);
     376        if (rc != EOK)
     377                return rc;
     378       
     379        return task_wait(&wait, texit, retval);
    285380}
    286381
  • uspace/lib/c/generic/time.c

    r8db09e4 r15d0046  
    555555                }
    556556               
    557                 void *addr;
     557                void *addr = AS_AREA_ANY;
    558558                rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE,
    559559                    &addr);
  • uspace/lib/c/include/adt/list.h

    r8db09e4 r15d0046  
    3939#include <assert.h>
    4040#include <stdbool.h>
    41 #include <unistd.h>
     41#include <stddef.h>
    4242
    4343/** Doubly linked list link. */
  • uspace/lib/c/include/async.h

    r8db09e4 r15d0046  
    4545#include <atomic.h>
    4646#include <stdbool.h>
    47 #include <task.h>
     47#include <abi/proc/task.h>
     48#include <abi/ddi/irq.h>
     49#include <abi/ipc/event.h>
    4850
    4951typedef ipc_callid_t aid_t;
     
    6264typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *);
    6365
    64 /** Interrupt handler */
    65 typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *);
     66/** Notification handler */
     67typedef void (*async_notification_handler_t)(ipc_callid_t, ipc_call_t *,
     68    void *);
    6669
    6770/** Exchange management style
     
    155158
    156159extern void async_set_client_connection(async_client_conn_t);
    157 extern void async_set_interrupt_received(async_interrupt_handler_t);
    158 extern void async_set_interrupt_handler_stack_size(size_t);
     160extern void async_set_notification_handler_stack_size(size_t);
     161
     162extern int async_irq_subscribe(int, int, async_notification_handler_t, void *,
     163    const irq_code_t *);
     164extern int async_irq_unsubscribe(int, int);
     165
     166extern int async_event_subscribe(event_type_t, async_notification_handler_t,
     167    void *);
     168extern int async_event_task_subscribe(event_task_type_t,
     169    async_notification_handler_t, void *);
     170extern int async_event_unsubscribe(event_type_t);
     171extern int async_event_task_unsubscribe(event_task_type_t);
     172extern int async_event_unmask(event_type_t);
     173extern int async_event_task_unmask(event_task_type_t);
    159174
    160175/*
  • uspace/lib/c/include/bd.h

    r8db09e4 r15d0046  
    4848extern int bd_read_toc(bd_t *, uint8_t, void *, size_t);
    4949extern int bd_write_blocks(bd_t *, aoff64_t, size_t, const void *, size_t);
     50extern int bd_sync_cache(bd_t *, aoff64_t, size_t);
    5051extern int bd_get_block_size(bd_t *, size_t *);
    5152extern int bd_get_num_blocks(bd_t *, aoff64_t *);
  • uspace/lib/c/include/bd_srv.h

    r8db09e4 r15d0046  
    6262        int (*read_blocks)(bd_srv_t *, aoff64_t, size_t, void *, size_t);
    6363        int (*read_toc)(bd_srv_t *, uint8_t, void *, size_t);
     64        int (*sync_cache)(bd_srv_t *, aoff64_t, size_t);
    6465        int (*write_blocks)(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
    6566        int (*get_block_size)(bd_srv_t *, size_t *);
  • uspace/lib/c/include/ddi.h

    r8db09e4 r15d0046  
    5151
    5252extern int physmem_map(uintptr_t, size_t, unsigned int, void **);
     53extern int physmem_unmap(void *);
    5354
    5455extern int dmamem_map(void *, size_t, unsigned int, unsigned int, uintptr_t *);
     
    6162extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **);
    6263extern int pio_enable(void *, size_t, void **);
     64extern int pio_disable(void *, size_t);
    6365
    6466typedef void (*trace_fnc)(const volatile void *place, uint32_t val,
     
    130132}
    131133
    132 extern int irq_register(int, int, int, const irq_code_t *);
    133 extern int irq_unregister(int, int);
    134 
    135134#endif
    136135
  • uspace/lib/c/include/fibril.h

    r8db09e4 r15d0046  
    6767typedef struct fibril {
    6868        link_t link;
     69        link_t all_link;
    6970        context_t ctx;
    7071        void *stack;
  • uspace/lib/c/include/fibril_synch.h

    r8db09e4 r15d0046  
    116116        /** Timer has fired and has not been cleared since */
    117117        fts_fired,
    118         /** Timer is being destroyed */
    119         fts_cleanup
     118        /** Timer fibril is requested to terminate */
     119        fts_cleanup,
     120        /** Timer fibril acknowledged termination */
     121        fts_clean
    120122} fibril_timer_state_t;
    121123
     
    129131typedef struct {
    130132        fibril_mutex_t lock;
     133        fibril_mutex_t *lockp;
    131134        fibril_condvar_t cv;
    132135        fid_t fibril;
    133136        fibril_timer_state_t state;
     137        bool handler_running;
    134138
    135139        suseconds_t delay;
     
    160164extern void fibril_condvar_broadcast(fibril_condvar_t *);
    161165
    162 extern fibril_timer_t *fibril_timer_create(void);
     166extern fibril_timer_t *fibril_timer_create(fibril_mutex_t *);
    163167extern void fibril_timer_destroy(fibril_timer_t *);
    164168extern void fibril_timer_set(fibril_timer_t *, suseconds_t, fibril_timer_fun_t,
    165169    void *);
     170extern void fibril_timer_set_locked(fibril_timer_t *, suseconds_t,
     171    fibril_timer_fun_t, void *);
    166172extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *);
     173extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *);
    167174
    168175#endif
  • uspace/lib/c/include/inet/iplink.h

    r8db09e4 r15d0046  
    7878typedef struct iplink_ev_ops {
    7979        int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
     80        int (*change_addr)(iplink_t *, addr48_t);
    8081} iplink_ev_ops_t;
    8182
     
    8889extern int iplink_get_mtu(iplink_t *, size_t *);
    8990extern int iplink_get_mac48(iplink_t *, addr48_t *);
     91extern int iplink_set_mac48(iplink_t *, addr48_t);
    9092
    9193#endif
  • uspace/lib/c/include/inet/iplink_srv.h

    r8db09e4 r15d0046  
    5959        int (*get_mtu)(iplink_srv_t *, size_t *);
    6060        int (*get_mac48)(iplink_srv_t *, addr48_t *);
     61        int (*set_mac48)(iplink_srv_t *, addr48_t *);
    6162        int (*addr_add)(iplink_srv_t *, inet_addr_t *);
    6263        int (*addr_remove)(iplink_srv_t *, inet_addr_t *);
     
    6768extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *);
    6869extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
     70extern int iplink_ev_change_addr(iplink_srv_t *, addr48_t *);
    6971
    7072#endif
  • uspace/lib/c/include/io/chardev.h

    r8db09e4 r15d0046  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvkbd
     28/** @addtogroup libc
    2929 * @{
    3030 */
    31 /** @file
    32  * @brief ps/2 mouse driver.
    33  */
    3431
    35 #ifndef _CHARDEV_H_
    36 #define _CHARDEV_H_
     32#ifndef LIBC_IO_CHARDEV_H_
     33#define LIBC_IO_CHARDEV_H_
    3734
    3835#include <libarch/types.h>
  • uspace/lib/c/include/io/input.h

    r8db09e4 r15d0046  
    4949
    5050typedef struct input_ev_ops {
     51        int (*active)(input_t *);
     52        int (*deactive)(input_t *);
    5153        int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t);
    5254        int (*move)(input_t *, int, int);
     
    5759extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **);
    5860extern void input_close(input_t *);
    59 extern int input_yield(input_t *);
    60 extern int input_reclaim(input_t *);
     61extern int input_activate(input_t *);
    6162
    6263#endif
  • uspace/lib/c/include/io/pixelmap.h

    r8db09e4 r15d0046  
    11/*
    22 * Copyright (c) 2011 Petr Koupy
     3 * Copyright (c) 2014 Martin Sucha
    34 * All rights reserved.
    45 *
     
    4041#include <unistd.h>
    4142#include <io/pixel.h>
     43
     44/* Defines how a pixel outside of pixmap rectangle shall be treated */
     45typedef enum {
     46        /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */
     47        PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,
     48       
     49        /* The pixmap is repeated infinetely */
     50        PIXELMAP_EXTEND_TILE,
     51       
     52        /* If outside of a pixmap, return closest pixel from the edge */
     53        PIXELMAP_EXTEND_SIDES,
     54       
     55        /* If outside of a pixmap, return closest pixel from the edge,
     56         * with alpha = 0
     57         */
     58        PIXELMAP_EXTEND_TRANSPARENT_SIDES
     59} pixelmap_extend_t;
    4260
    4361typedef struct {
     
    86104}
    87105
     106static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,
     107    native_t x, native_t y, pixelmap_extend_t extend)
     108{
     109        bool transparent = false;
     110        if (extend == PIXELMAP_EXTEND_TILE) {
     111                x %= pixmap->width;
     112                y %= pixmap->height;
     113        }
     114        else if (extend == PIXELMAP_EXTEND_SIDES ||
     115            extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {
     116                bool transparent_outside =
     117                    (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);
     118                if (x < 0) {
     119                        x = 0;
     120                        transparent = transparent_outside;
     121                }
     122                else if (((sysarg_t) x) >= pixmap->width) {
     123                        x = pixmap->width - 1;
     124                        transparent = transparent_outside;
     125                }
     126               
     127                if (y < 0) {
     128                        y = 0;
     129                        transparent = transparent_outside;
     130                }
     131                else if (((sysarg_t) y) >= pixmap->height) {
     132                        y = pixmap->height - 1;
     133                        transparent = transparent_outside;
     134                }
     135        }
     136       
     137        if (x < 0 || ((sysarg_t) x) >= pixmap->width ||
     138            y < 0 || ((sysarg_t) y) >= pixmap->height)
     139                return PIXEL(0, 0, 0, 0);
     140
     141        pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);
     142       
     143        if (transparent)
     144                pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));
     145       
     146        return pixel;
     147}
     148
     149
    88150#endif
    89151
  • uspace/lib/c/include/ipc/bd.h

    r8db09e4 r15d0046  
    4242        BD_GET_NUM_BLOCKS,
    4343        BD_READ_BLOCKS,
     44        BD_SYNC_CACHE,
    4445        BD_WRITE_BLOCKS,
    4546        BD_READ_TOC
  • uspace/lib/c/include/ipc/chardev.h

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2003-2004 Jakub Jermar
     2 * Copyright (c) 2014 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mips64
     29/** @addtogroup libcipc
    3030 * @{
    3131 */
    3232/** @file
     33 * @brief Character device interface.
    3334 */
    3435
    35 #ifndef KERN_mips64_CPU_H_
    36 #define KERN_mips64_CPU_H_
     36#ifndef LIBC_IPC_CHARDEV_H_
     37#define LIBC_IPC_CHARDEV_H_
    3738
    38 #include <typedefs.h>
    39 #include <arch/asm.h>
     39#include <ipc/common.h>
    4040
    41 typedef struct {
    42         uint32_t imp_num;
    43         uint32_t rev_num;
    44 } cpu_arch_t;
     41typedef enum {
     42        CHARDEV_READ = IPC_FIRST_USER_METHOD,
     43        CHARDEV_WRITE
     44} chardev_request_t;
    4545
    4646#endif
  • uspace/lib/c/include/ipc/common.h

    r8db09e4 r15d0046  
    3939#include <abi/ipc/ipc.h>
    4040#include <atomic.h>
    41 #include <task.h>
     41#include <abi/proc/task.h>
    4242
    4343#define IPC_FLAG_BLOCKING  0x01
  • uspace/lib/c/include/ipc/dev_iface.h

    r8db09e4 r15d0046  
    4141        CHAR_DEV_IFACE,
    4242
    43         /** Graphic device interface */
    44         GRAPH_DEV_IFACE,
    45 
    4643        /** Audio device mixer interface */
    4744        AUDIO_MIXER_IFACE,
     
    6461        /** Interface provided by Real Time Clock devices */
    6562        CLOCK_DEV_IFACE,
     63
     64        /** Interface provided by LED devices */
     65        LED_DEV_IFACE,
    6666
    6767        /** Interface provided by battery powered devices */
  • uspace/lib/c/include/ipc/event.h

    r8db09e4 r15d0046  
    3333 */
    3434
    35 #ifndef LIBC_EVENT_H_
    36 #define LIBC_EVENT_H_
     35#ifndef LIBC_IPC_EVENT_H_
     36#define LIBC_IPC_EVENT_H_
    3737
    3838#include <abi/ipc/event.h>
    3939#include <libarch/types.h>
    4040
    41 extern int event_subscribe(event_type_t, sysarg_t);
    42 extern int event_task_subscribe(event_task_type_t, sysarg_t);
    43 extern int event_unmask(event_type_t);
    44 extern int event_task_unmask(event_task_type_t);
     41extern int ipc_event_subscribe(event_type_t, sysarg_t);
     42extern int ipc_event_task_subscribe(event_task_type_t, sysarg_t);
     43extern int ipc_event_unsubscribe(event_type_t);
     44extern int ipc_event_task_unsubscribe(event_task_type_t);
     45extern int ipc_event_unmask(event_type_t);
     46extern int ipc_event_task_unmask(event_task_type_t);
    4547
    4648#endif
  • uspace/lib/c/include/ipc/input.h

    r8db09e4 r15d0046  
    3939
    4040typedef enum {
    41         INPUT_YIELD = IPC_FIRST_USER_METHOD,
    42         INPUT_RECLAIM
     41        INPUT_ACTIVATE = IPC_FIRST_USER_METHOD
    4342} input_request_t;
    4443
    4544typedef enum {
    46         INPUT_EVENT_KEY = IPC_FIRST_USER_METHOD,
     45        INPUT_EVENT_ACTIVE = IPC_FIRST_USER_METHOD,
     46        INPUT_EVENT_DEACTIVE,
     47        INPUT_EVENT_KEY,
    4748        INPUT_EVENT_MOVE,
    4849        INPUT_EVENT_ABS_MOVE,
  • uspace/lib/c/include/ipc/ipc.h

    r8db09e4 r15d0046  
    4444#include <abi/ipc/methods.h>
    4545#include <abi/synch.h>
    46 #include <task.h>
     46#include <abi/proc/task.h>
    4747
    4848typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *);
  • uspace/lib/c/include/ipc/iplink.h

    r8db09e4 r15d0046  
    4141        IPLINK_GET_MTU = IPC_FIRST_USER_METHOD,
    4242        IPLINK_GET_MAC48,
     43        IPLINK_SET_MAC48,
    4344        IPLINK_SEND,
    4445        IPLINK_SEND6,
     
    4849
    4950typedef enum {
    50         IPLINK_EV_RECV = IPC_FIRST_USER_METHOD
     51        IPLINK_EV_RECV = IPC_FIRST_USER_METHOD,
     52        IPLINK_EV_CHANGE_ADDR,
    5153} iplink_event_t;
    5254
  • uspace/lib/c/include/ipc/irc.h

    r8db09e4 r15d0046  
    3333 */
    3434
    35 #ifndef LIBC_IRC_H_
    36 #define LIBC_IRC_H_
     35#ifndef LIBC_IPC_IRC_H_
     36#define LIBC_IPC_IRC_H_
    3737
    3838#include <ipc/common.h>
  • uspace/lib/c/include/ipc/irq.h

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2003-2004 Jakub Jermar
     2 * Copyright (c) 2014 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mips64
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_mips64_CACHE_H_
    36 #define KERN_mips64_CACHE_H_
     35#ifndef LIBC_IPC_IRQ_H_
     36#define LIBC_IPC_IRQ_H_
    3737
    38 #include <arch/exception.h>
     38#include <sys/types.h>
     39#include <abi/ddi/irq.h>
    3940
    40 extern void cache_error(istate_t *);
     41extern int ipc_irq_subscribe(int, int, sysarg_t, const irq_code_t *);
     42extern int ipc_irq_unsubscribe(int, int);
    4143
    4244#endif
  • uspace/lib/c/include/irc.h

    r8db09e4 r15d0046  
    11/*
    2  * Copyright (c) 2011 Petr Koupy
     2 * Copyright (c) 2014 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3333 */
    3434
    35 #ifndef LIBC_DEVICE_GRAPH_DEV_H_
    36 #define LIBC_DEVICE_GRAPH_DEV_H_
     35#ifndef LIBC_IRC_H_
     36#define LIBC_IRC_H_
    3737
    38 #include <async.h>
    39 
    40 extern int graph_dev_connect(async_sess_t *);
     38extern int irc_enable_interrupt(int);
     39extern int irc_disable_interrupt(int);
    4140
    4241#endif
  • uspace/lib/c/include/loader/loader.h

    r8db09e4 r15d0046  
    3737#define LIBC_LOADER_H_
    3838
    39 #include <task.h>
     39#include <abi/proc/task.h>
    4040
    4141/** Forward declararion */
  • uspace/lib/c/include/stacktrace.h

    r8db09e4 r15d0046  
    4141
    4242typedef struct {
     43        int (*read_uintptr)(void *, uintptr_t, uintptr_t *);
     44} stacktrace_ops_t;
     45
     46typedef struct {
    4347        void *op_arg;
    44         int (*read_uintptr)(void *, uintptr_t, uintptr_t *);
     48        stacktrace_ops_t *ops;
    4549} stacktrace_t;
    4650
    4751extern void stacktrace_print(void);
    4852extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t);
     53extern void stacktrace_print_generic(stacktrace_ops_t *, void *, uintptr_t,
     54    uintptr_t);
    4955
    5056/*
  • uspace/lib/c/include/stddef.h

    r8db09e4 r15d0046  
    3838#include <sys/types.h>
    3939
     40#ifndef NULL
     41        #define NULL  ((void *) 0)
     42#endif
     43
     44
    4045#endif
    4146
  • uspace/lib/c/include/stdio.h

    r8db09e4 r15d0046  
    120120extern int snprintf(char *, size_t , const char *, ...)
    121121    PRINTF_ATTRIBUTE(3, 4);
     122extern int vasprintf(char **, const char *, va_list);
    122123extern int asprintf(char **, const char *, ...)
    123124    PRINTF_ATTRIBUTE(2, 3);
  • uspace/lib/c/include/str.h

    r8db09e4 r15d0046  
    109109extern char *str_ndup(const char *, size_t max_size);
    110110
     111extern char *str_tok(char *, const char *, char **);
     112
    111113extern int str_uint8_t(const char *, const char **, unsigned int, bool,
    112114    uint8_t *);
     
    132134extern unsigned long strtoul(const char *, char **, int);
    133135
    134 extern char * strtok_r(char *, const char *, char **);
    135 extern char * strtok(char *, const char *);
    136 
    137136#endif
    138137
  • uspace/lib/c/include/task.h

    r8db09e4 r15d0046  
    3939#include <abi/proc/task.h>
    4040#include <stdarg.h>
     41#include <async.h>
     42#include <types/task.h>
    4143
    42 typedef enum {
    43         TASK_EXIT_NORMAL,
    44         TASK_EXIT_UNEXPECTED
    45 } task_exit_t;
     44typedef struct {
     45        ipc_call_t result;
     46        aid_t aid;
     47} task_wait_t;
     48
     49struct _TASK;
     50typedef struct _TASK task_t;
    4651
    4752extern task_id_t task_get_id(void);
     
    4954extern int task_kill(task_id_t);
    5055
    51 extern int task_spawnv(task_id_t *, const char *path, const char *const []);
    52 extern int task_spawnvf(task_id_t *, const char *path, const char *const [],
    53     int *const []);
    54 extern int task_spawn(task_id_t *, const char *path, int, va_list ap);
    55 extern int task_spawnl(task_id_t *, const char *path, ...);
     56extern int task_spawnv(task_id_t *, task_wait_t *, const char *path,
     57    const char *const []);
     58extern int task_spawnvf(task_id_t *, task_wait_t *, const char *path,
     59    const char *const [], int *const []);
     60extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int,
     61    va_list ap);
     62extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...);
    5663
    57 extern int task_wait(task_id_t id, task_exit_t *, int *);
     64extern int task_setup_wait(task_id_t, task_wait_t *);
     65extern void task_cancel_wait(task_wait_t *);
     66extern int task_wait(task_wait_t *, task_exit_t *, int *);
     67extern int task_wait_task_id(task_id_t, task_exit_t *, int *);
    5868extern int task_retval(int);
    5969
  • uspace/lib/c/include/types/task.h

    r8db09e4 r15d0046  
    2727 */
    2828
    29 /** @addtogroup mips64proc
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_mips64_TASK_H_
    36 #define KERN_mips64_TASK_H_
     35#ifndef LIBC_TYPES_TASK_H_
     36#define LIBC_TYPES_TASK_H_
    3737
    38 typedef struct {
    39 } task_arch_t;
    40 
    41 #define task_create_arch(task)
    42 #define task_destroy_arch(task)
     38typedef enum {
     39        TASK_EXIT_NORMAL,
     40        TASK_EXIT_UNEXPECTED
     41} task_exit_t;
    4342
    4443#endif
Note: See TracChangeset for help on using the changeset viewer.