Changeset 15d0046 in mainline for uspace/lib/c
- Timestamp:
- 2014-09-12T13:22:33Z (11 years ago)
- 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. - Location:
- uspace/lib/c
- Files:
-
- 18 added
- 30 deleted
- 75 edited
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r8db09e4 r15d0046 50 50 -include arch/$(UARCH)/Makefile.inc 51 51 52 ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG))) 53 ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG))) 54 ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG))) 55 56 PRE_DEPEND += $(ARCH_AUTOGENS_H) 57 EXTRA_CLEAN += $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S) 58 52 59 GENERIC_SOURCES = \ 53 60 generic/libc.c \ … … 65 72 generic/device/pio_window.c \ 66 73 generic/device/clock_dev.c \ 74 generic/device/led_dev.c \ 67 75 generic/dhcp.c \ 68 76 generic/dnsr.c \ … … 91 99 generic/io/input.c \ 92 100 generic/io/io.c \ 101 generic/io/chardev.c \ 102 generic/io/chardev_srv.c \ 93 103 generic/io/chargrid.c \ 94 104 generic/io/output.c \ … … 108 118 generic/iplink.c \ 109 119 generic/iplink_srv.c \ 120 generic/irc.c \ 121 generic/irq.c \ 110 122 generic/ieee_double.c \ 111 123 generic/power_of_ten.c \ … … 159 171 include $(USPACE_PREFIX)/Makefile.common 160 172 173 %.h: %.ag 174 $(AUTOGEN) probe $< >$<.probe.c 175 $(CC) $(DEFS) $(CFLAGS) -S -o $<.probe.s $<.probe.c 176 $(AUTOGEN) generate $< <$<.probe.s >$@ 177 161 178 $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in 162 179 $(CC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@ -
uspace/lib/c/arch/amd64/Makefile.inc
r8db09e4 r15d0046 37 37 arch/$(UARCH)/src/stacktrace_asm.S 38 38 39 ARCH_AUTOGENS_AG = \ 40 arch/$(UARCH)/include/libarch/istate_struct.ag \ 41 arch/$(UARCH)/include/libarch/fibril_context.ag 42 39 43 .PRECIOUS: arch/$(UARCH)/src/entry.o 44 -
uspace/lib/c/arch/amd64/include/libarch/fibril.h
r8db09e4 r15d0046 36 36 #define LIBC_amd64_FIBRIL_H_ 37 37 38 #include < sys/types.h>38 #include <libarch/fibril_context.h> 39 39 40 40 /* … … 53 53 } while (0) 54 54 55 /* We include only registers that must be preserved56 * during function call57 */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 73 55 static inline uintptr_t context_get_fp(context_t *ctx) 74 56 { -
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 3 2 # All rights reserved. 4 3 # … … 27 26 # 28 27 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, 37 30 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 ], 41 36 42 POSIX_COMPAT = y 37 members : [ 38 # 39 # We include only registers that must be preserved 40 # during function call. 41 # 43 42 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 }, 45 51 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 }, 72 60 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 }, 74 77 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 32 32 .global context_restore 33 33 34 #include <libarch/ context_offset.h>34 #include <libarch/fibril_context.h> 35 35 36 36 ## Save current CPU context … … 42 42 movq (%rsp), %rdx # the caller's return %eip 43 43 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) 46 54 47 55 # save TLS 48 56 movq %fs:0, %rax 49 movq %rax, OFFSET_TLS(%rdi)57 movq %rax, CONTEXT_OFFSET_TLS(%rdi) 50 58 51 xorl %eax, %eax # context_save returns 159 xorl %eax, %eax # context_save returns 1 52 60 incl %eax 53 61 ret … … 60 68 context_restore: 61 69 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 63 80 64 81 movq %rdx,(%rsp) 65 82 66 83 # Set thread local storage 67 movq OFFSET_TLS(%rdi), %rdi # Set arg1 to TLS addr68 movl $1, %eax # SYS_TLS_SET84 movq CONTEXT_OFFSET_TLS(%rdi), %rdi # Set arg1 to TLS addr 85 movl $1, %eax # SYS_TLS_SET 69 86 syscall 70 87 71 xorl %eax, %eax # context_restore returns 088 xorl %eax, %eax # context_restore returns 0 72 89 ret 90 -
uspace/lib/c/arch/amd64/src/stacktrace.c
r8db09e4 r15d0046 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/arm32/Makefile.inc
r8db09e4 r15d0046 39 39 arch/$(UARCH)/src/stacktrace_asm.S 40 40 41 ARCH_AUTOGENS_AG = \ 42 arch/$(UARCH)/include/libarch/istate_struct.ag \ 43 arch/$(UARCH)/include/libarch/fibril_context.ag 44 41 45 .PRECIOUS: arch/$(UARCH)/src/entry.o 46 -
uspace/lib/c/arch/arm32/include/libarch/fibril.h
r8db09e4 r15d0046 40 40 #include <align.h> 41 41 #include <thread.h> 42 #include <libarch/fibril_context.h> 42 43 43 44 /** Size of a stack item */ … … 66 67 } while (0) 67 68 68 /** Fibril context.69 *70 * Only registers preserved accross function calls are included. r9 is used71 * to store a TLS address. -ffixed-r9 gcc forces gcc not to use this72 * register. -mtp=soft forces gcc to use #__aeabi_read_tp to obtain73 * 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 88 69 static inline uintptr_t context_get_fp(context_t *ctx) 89 70 { -
uspace/lib/c/arch/arm32/src/stacktrace.c
r8db09e4 r15d0046 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/ia32/Makefile.inc
r8db09e4 r15d0046 39 39 arch/$(UARCH)/src/rtld/reloc.c 40 40 41 ARCH_AUTOGENS_AG = \ 42 arch/$(UARCH)/include/libarch/istate_struct.ag \ 43 arch/$(UARCH)/include/libarch/fibril_context.ag 44 41 45 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/ia32/include/libarch/fibril.h
r8db09e4 r15d0046 37 37 38 38 #include <sys/types.h> 39 #include <libarch/fibril_context.h> 39 40 40 41 /* … … 53 54 } while (0) 54 55 55 /*56 * We include only registers that must be preserved57 * during function call58 */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 71 56 static inline uintptr_t context_get_fp(context_t *ctx) 72 57 { -
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 3 2 # All rights reserved. 4 3 # … … 27 26 # 28 27 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, 36 30 37 POSIX_COMPAT = y 31 includes : [ 32 { 33 include : <sys/types.h> 34 } 35 ], 38 36 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 # 41 42 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 }, 43 51 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 }, 48 68 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 27 27 # 28 28 29 #include <libarch/ context_offset.h>29 #include <libarch/fibril_context.h> 30 30 31 31 .text … … 44 44 45 45 # 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 47 52 48 53 # save TLS 49 54 movl %gs:0, %eax 50 movl %eax, OFFSET_TLS(%edx)# tls -> ctx->tls55 movl %eax, CONTEXT_OFFSET_TLS(%edx) # tls -> ctx->tls 51 56 52 xorl %eax, %eax 57 xorl %eax, %eax # context_save returns 1 53 58 incl %eax 54 59 ret … … 63 68 64 69 # 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 66 76 67 77 movl %edx, 0(%esp) # ctx->pc -> saver's return %eip … … 69 79 # set thread local storage 70 80 pushl %edx 71 movl OFFSET_TLS(%eax), %edx# Set arg1 to TLS addr72 movl $1, %eax 81 movl CONTEXT_OFFSET_TLS(%eax), %edx # Set arg1 to TLS addr 82 movl $1, %eax # Syscall SYS_TLS_SET 73 83 int $0x30 74 84 popl %edx 75 85 76 xorl %eax, %eax 86 xorl %eax, %eax # context_restore returns 0 77 87 ret 88 -
uspace/lib/c/arch/ia32/src/stacktrace.c
r8db09e4 r15d0046 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/ia64/Makefile.common
r8db09e4 r15d0046 27 27 # 28 28 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 29 GCC_CFLAGS += -fno-unwind-tables 40 30 41 31 ENDIANESS = LE -
uspace/lib/c/arch/ia64/Makefile.inc
r8db09e4 r15d0046 38 38 arch/$(UARCH)/src/stacktrace_asm.S 39 39 40 ARCH_AUTOGENS_AG = \ 41 arch/$(UARCH)/include/libarch/istate_struct.ag \ 42 arch/$(UARCH)/include/libarch/fibril_context.ag 43 40 44 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/ia64/include/libarch/fibril.h
r8db09e4 r15d0046 40 40 #include <libarch/stack.h> 41 41 #include <libarch/types.h> 42 #include <libarch/fibril_context.h> 42 43 43 44 /* … … 64 65 } while (0) 65 66 66 /*67 * Only save registers that must be preserved across68 * function calls.69 */70 typedef struct context {71 72 /*73 * Application registers74 */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 registers85 */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 registers96 */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 registers106 */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 133 67 static inline uintptr_t context_get_fp(context_t *ctx) 134 68 { -
uspace/lib/c/arch/ia64/include/libarch/types.h
r8db09e4 r15d0046 49 49 uint64_t lo; 50 50 int64_t hi; 51 } int128_t;51 } __attribute__((aligned(16))) int128_t; 52 52 53 53 typedef struct { 54 54 uint64_t lo; 55 55 uint64_t hi; 56 } uint128_t;56 } __attribute__((aligned(16))) uint128_t; 57 57 58 58 typedef uint64_t sysarg_t; -
uspace/lib/c/arch/ia64/src/fibril.S
r8db09e4 r15d0046 27 27 # 28 28 29 #include <libarch/fibril_context.h> 30 29 31 .text 30 32 … … 33 35 34 36 context_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 ;; 38 39 mov loc3 = ar.rsc 39 40 … … 58 59 59 60 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 60 121 61 122 /* 62 123 * Save application registers 63 124 */ 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 */ 86 132 87 133 /* 88 134 * Save branch registers 89 135 */ 90 mov loc2 = b0 ;;91 st8 [in0] = loc2, 8 /* save pc */92 mov loc 3 = b1 ;;93 st8 [in0] = loc3, 894 mov loc 4 = b2 ;;95 st8 [in0] = loc4, 896 mov loc5 = b3 ;;97 st8 [ in0] = loc5, 898 mov loc6 = b4 ;;99 st8 [ in0] = loc6, 8100 mov loc7 = b5 ;;101 st8 [ in0] = loc7, 8136 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 ;; 102 148 103 149 /* 104 150 * Save predicate registers 105 151 */ 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 108 154 109 155 /* 110 156 * Save floating-point registers. 111 157 */ 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 133 179 134 180 mov ar.unat = loc1 135 181 136 add r8 = r0, r0, 1 182 add r8 = r0, r0, 1 /* context_save returns 1 */ 137 183 br.ret.sptk.many b0 138 184 139 185 context_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 */ 149 242 150 243 .auto … … 180 273 .explicit 181 274 182 mov ar.unat = loc2 275 mov ar.unat = loc2 ;; 183 276 mov ar.lc = loc6 184 277 … … 186 279 * Restore general registers including NaT bits 187 280 */ 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] ;; 195 288 196 289 /* 197 290 * Restore branch registers 198 291 */ 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] ;; 200 298 mov b0 = loc2 201 ld8 loc3 = [in0], 8 ;;202 299 mov b1 = loc3 203 ld8 loc4 = [in0], 8 ;;204 300 mov b2 = loc4 205 ld8 loc5 = [in0], 8 ;;206 301 mov b3 = loc5 207 ld8 loc6 = [in0], 8 ;;208 302 mov b4 = loc6 209 ld8 loc7 = [in0], 8 ;; 210 mov b5 = loc7 303 mov b5 = loc7 ;; 211 304 212 305 /* 213 306 * Restore predicate registers 214 307 */ 215 ld8 loc2 = [ in0], 16;;308 ld8 loc2 = [loc29] ;; 216 309 mov pr = loc2, ~0 217 310 … … 219 312 * Restore floating-point registers. 220 313 */ 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] 242 335 243 336 mov ar.unat = loc1 -
uspace/lib/c/arch/mips32/Makefile.inc
r8db09e4 r15d0046 37 37 arch/$(UARCH)/src/stacktrace_asm.S 38 38 39 ARCH_AUTOGENS_AG = \ 40 arch/$(UARCH)/include/libarch/istate_struct.ag \ 41 arch/$(UARCH)/include/libarch/fibril_context.ag 42 39 43 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/mips32/include/libarch/fibril.h
r8db09e4 r15d0046 38 38 39 39 #include <sys/types.h> 40 #include <libarch/fibril_context.h> 40 41 #include <libarch/stack.h> 41 42 #include <align.h> … … 56 57 } while (0) 57 58 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 88 59 static inline uintptr_t context_get_fp(context_t *ctx) 89 60 { -
uspace/lib/c/arch/mips32/src/fibril.S
r8db09e4 r15d0046 32 32 .set noreorder 33 33 34 #include <libarch/ context_offset.h>34 #include <libarch/fibril_context.h> 35 35 36 36 .global context_save … … 38 38 39 39 context_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) 41 90 42 91 # context_save returns 1 … … 45 94 46 95 context_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) 48 145 49 146 # Just for the jump into first function, -
uspace/lib/c/arch/mips32eb/Makefile.inc
r8db09e4 r15d0046 37 37 arch/$(UARCH)/src/stacktrace_asm.S 38 38 39 ARCH_AUTOGENS_AG = \ 40 arch/$(UARCH)/include/libarch/istate_struct.ag \ 41 arch/$(UARCH)/include/libarch/fibril_context.ag 42 39 43 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/ppc32/Makefile.common
r8db09e4 r15d0046 27 27 # 28 28 29 GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32 29 30 ifeq ($(CONFIG_FPU),y) 31 FLOATS=hard 32 else 33 FLOATS=soft 34 endif 35 36 GCC_CFLAGS += -mcpu=powerpc -m$(FLOATS)-float -m32 30 37 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a 31 38 AFLAGS = -a32 -
uspace/lib/c/arch/ppc32/Makefile.inc
r8db09e4 r15d0046 37 37 arch/$(UARCH)/src/stacktrace_asm.S 38 38 39 ARCH_AUTOGENS_AG = \ 40 arch/$(UARCH)/include/libarch/istate_struct.ag \ 41 arch/$(UARCH)/include/libarch/fibril_context.ag 42 39 43 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/ppc32/include/libarch/fibril.h
r8db09e4 r15d0046 37 37 38 38 #include <sys/types.h> 39 #include <libarch/fibril_context.h> 39 40 40 41 #define SP_DELTA 16 … … 53 54 } while (0) 54 55 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 83 56 static inline uintptr_t context_get_fp(context_t *ctx) 84 57 { -
uspace/lib/c/arch/ppc32/src/fibril.S
r8db09e4 r15d0046 33 33 34 34 #include <libarch/regname.h> 35 #include <libarch/ context_offset.h>35 #include <libarch/fibril_context.h> 36 36 37 37 context_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) 39 59 40 60 mflr r4 41 stw r4, OFFSET_PC(r3)61 stw r4, CONTEXT_OFFSET_PC(r3) 42 62 43 63 mfcr r4 44 stw r4, OFFSET_CR(r3)64 stw r4, CONTEXT_OFFSET_CR(r3) 45 65 46 66 # context_save returns 1 … … 50 70 51 71 context_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) 53 93 54 lwz r4, OFFSET_CR(r3)94 lwz r4, CONTEXT_OFFSET_CR(r3) 55 95 mtcr r4 56 96 57 lwz r4, OFFSET_PC(r3)97 lwz r4, CONTEXT_OFFSET_PC(r3) 58 98 mtlr r4 59 99 -
uspace/lib/c/arch/ppc32/src/stacktrace.c
r8db09e4 r15d0046 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/sparc32/src/stacktrace.c
r8db09e4 r15d0046 53 53 { 54 54 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, 56 56 &bprev); 57 57 if (rc == EOK) … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 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); 66 66 } 67 67 -
uspace/lib/c/arch/sparc64/Makefile.inc
r8db09e4 r15d0046 36 36 arch/$(UARCH)/src/stacktrace_asm.S 37 37 38 ARCH_AUTOGENS_AG = \ 39 arch/$(UARCH)/include/libarch/istate_struct.ag \ 40 arch/$(UARCH)/include/libarch/fibril_context.ag 41 38 42 .PRECIOUS: arch/$(UARCH)/src/entry.o -
uspace/lib/c/arch/sparc64/_link.ld.in
r8db09e4 r15d0046 10 10 #endif 11 11 data PT_LOAD FLAGS(6); 12 debug PT_NOTE; 12 13 } 13 14 … … 63 64 } :data 64 65 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 65 79 /DISCARD/ : { 66 80 *(*); -
uspace/lib/c/arch/sparc64/include/libarch/fibril.h
r8db09e4 r15d0046 37 37 38 38 #include <libarch/stack.h> 39 #include <libarch/fibril_context.h> 39 40 #include <sys/types.h> 40 41 #include <align.h> … … 51 52 } while (0) 52 53 53 /*54 * Save only registers that must be preserved across55 * 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 79 54 static inline uintptr_t context_get_fp(context_t *ctx) 80 55 { -
uspace/lib/c/arch/sparc64/src/fibril.S
r8db09e4 r15d0046 27 27 # 28 28 29 #include <libarch/ context_offset.h>29 #include <libarch/fibril_context.h> 30 30 31 31 .text … … 39 39 # should a thread switch occur. 40 40 # 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] 42 60 retl 43 61 mov 1, %o0 ! context_save_arch returns 1 … … 52 70 flushw 53 71 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 55 91 retl 56 92 xor %o0, %o0, %o0 ! context_restore_arch returns 0 -
uspace/lib/c/arch/sparc64/src/stacktrace.c
r8db09e4 r15d0046 55 55 int rc; 56 56 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); 58 58 if (rc == EOK) 59 59 *prev = bprev + STACK_BIAS; … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 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); 66 66 } 67 67 -
uspace/lib/c/generic/adt/hash_table.c
r8db09e4 r15d0046 370 370 */ 371 371 if (!f(cur_link, arg)) 372 return;373 } 374 } 375 372 goto out; 373 } 374 } 375 out: 376 376 h->apply_ongoing = false; 377 377 -
uspace/lib/c/generic/async.c
r8db09e4 r15d0046 101 101 #undef LIBC_ASYNC_C_ 102 102 103 #include <ipc/irq.h> 104 #include <ipc/event.h> 103 105 #include <futex.h> 104 106 #include <fibril.h> … … 116 118 #include "private/libc.h" 117 119 118 119 120 /** Session data */ 120 121 struct async_sess { … … 242 243 async_client_conn_t cfibril; 243 244 } connection_t; 245 246 /* Notification data */ 247 typedef 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; 244 259 245 260 /** Identifier of the incoming connection handled by the current fibril. */ … … 335 350 } 336 351 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 350 352 static 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; 353 static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE; 353 354 354 355 /** Setter for client_connection function pointer. … … 363 364 } 364 365 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. 376 367 * 377 368 * @param size Stack size in bytes. 378 369 */ 379 void async_set_ interrupt_handler_stack_size(size_t size)380 { 381 interrupt_handler_stksz = size;370 void async_set_notification_handler_stack_size(size_t size) 371 { 372 notification_handler_stksz = size; 382 373 } 383 374 … … 399 390 static hash_table_t client_hash_table; 400 391 static hash_table_t conn_hash_table; 392 static hash_table_t notification_hash_table; 401 393 static LIST_INITIALIZE(timeout_list); 402 394 403 static size_t client_key_hash(void *k) 404 { 405 task_id_t key = *(task_id_t*)k; 406 return key; 395 static sysarg_t notification_avail = 0; 396 397 static size_t client_key_hash(void *key) 398 { 399 task_id_t in_task_id = *(task_id_t *) key; 400 return in_task_id; 407 401 } 408 402 … … 413 407 } 414 408 415 static bool client_key_equal(void *k , const ht_link_t *item)416 { 417 task_id_t key = *(task_id_t*)k;409 static bool client_key_equal(void *key, const ht_link_t *item) 410 { 411 task_id_t in_task_id = *(task_id_t *) key; 418 412 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 } 422 415 423 416 /** Operations for the client hash table. */ … … 439 432 static size_t conn_key_hash(void *key) 440 433 { 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; 443 436 } 444 437 … … 451 444 static bool conn_key_equal(void *key, const ht_link_t *item) 452 445 { 453 sysarg_t in_phone_hash = *(sysarg_t *)key;446 sysarg_t in_phone_hash = *(sysarg_t *) key; 454 447 connection_t *conn = hash_table_get_inst(item, connection_t, link); 455 448 return (in_phone_hash == conn->in_phone_hash); 456 449 } 457 458 450 459 451 /** Operations for the connection hash table. */ … … 462 454 .key_hash = conn_key_hash, 463 455 .key_equal = conn_key_equal, 456 .equal = NULL, 457 .remove_callback = NULL 458 }; 459 460 static size_t notification_key_hash(void *key) 461 { 462 sysarg_t id = *(sysarg_t *) key; 463 return id; 464 } 465 466 static 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(¬ification->imethod); 471 } 472 473 static 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. */ 482 static hash_table_ops_t notification_hash_table_ops = { 483 .hash = notification_hash, 484 .key_hash = notification_key_hash, 485 .key_equal = notification_key_equal, 464 486 .equal = NULL, 465 487 .remove_callback = NULL … … 511 533 futex_down(&async_futex); 512 534 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) { 516 537 futex_up(&async_futex); 517 538 return false; 518 539 } 519 540 520 connection_t *conn = hash_table_get_inst( hlp, connection_t, link);541 connection_t *conn = hash_table_get_inst(link, connection_t, link); 521 542 522 543 msg_t *msg = malloc(sizeof(*msg)); … … 553 574 * 554 575 * 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. 556 578 * 557 579 * @param arg Message structure pointer. … … 565 587 566 588 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(¬ification_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); 568 607 569 608 free(msg); … … 571 610 } 572 611 573 /** Process interruptnotification.612 /** Process notification. 574 613 * 575 614 * A new fibril is created which would process the notification. … … 598 637 599 638 fid_t fid = fibril_create_generic(notification_fibril, msg, 600 interrupt_handler_stksz);639 notification_handler_stksz); 601 640 if (fid == 0) { 602 641 free(msg); … … 609 648 futex_up(&async_futex); 610 649 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 */ 663 int 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(¬ification_hash_table, ¬ification->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 */ 695 int 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 */ 712 int 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(¬ification_hash_table, ¬ification->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 */ 745 int 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(¬ification_hash_table, ¬ification->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 */ 776 int 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 */ 788 int async_event_task_unmask(event_task_type_t evno) 789 { 790 return ipc_event_task_unmask(evno); 611 791 } 612 792 … … 702 882 703 883 futex_down(&async_futex); 704 ht_link_t *l nk = hash_table_find(&client_hash_table, &client_id);705 if (l nk) {706 client = hash_table_get_inst(l nk, 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); 707 887 atomic_inc(&client->refcnt); 708 888 } else if (create) { … … 1106 1286 1107 1287 if (!hash_table_create(&conn_hash_table, 0, 0, &conn_hash_table_ops)) 1288 abort(); 1289 1290 if (!hash_table_create(¬ification_hash_table, 0, 0, 1291 ¬ification_hash_table_ops)) 1108 1292 abort(); 1109 1293 -
uspace/lib/c/generic/bd.c
r8db09e4 r15d0046 150 150 } 151 151 152 int 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 152 163 int bd_get_block_size(bd_t *bd, size_t *rbsize) 153 164 { -
uspace/lib/c/generic/bd_srv.c
r8db09e4 r15d0046 128 128 } 129 129 130 static 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 130 149 static void bd_write_blocks_srv(bd_srv_t *srv, ipc_callid_t callid, 131 150 ipc_call_t *call) … … 190 209 bd_srv_t *srv; 191 210 192 srv = calloc(1, sizeof( srv));211 srv = calloc(1, sizeof(bd_srv_t)); 193 212 if (srv == NULL) 194 213 return NULL; … … 244 263 bd_read_toc_srv(srv, callid, &call); 245 264 break; 265 case BD_SYNC_CACHE: 266 bd_sync_cache_srv(srv, callid, &call); 267 break; 246 268 case BD_WRITE_BLOCKS: 247 269 bd_write_blocks_srv(srv, callid, &call); -
uspace/lib/c/generic/ddi.c
r8db09e4 r15d0046 71 71 * @param flags Flags for the new address space area. 72 72 * @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. 77 79 * @return ENOMEM if there was some problem in creating 78 80 * the address space area. … … 85 87 } 86 88 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 */ 99 int 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 */ 87 124 int dmamem_map(void *virt, size_t size, unsigned int map_flags, 88 125 unsigned int flags, uintptr_t *phys) … … 93 130 } 94 131 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 */ 95 152 int dmamem_map_anonymous(size_t size, uintptr_t constraint, 96 153 unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt) … … 137 194 138 195 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 */ 211 static 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); 139 220 } 140 221 … … 221 302 size_t pages = SIZE2PAGES(offset + size); 222 303 223 void *virt_page ;304 void *virt_page = AS_AREA_ANY; 224 305 int rc = physmem_map(phys_frame, pages, 225 306 AS_AREA_READ | AS_AREA_WRITE, &virt_page); … … 231 312 } 232 313 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 */ 323 int 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 233 334 void pio_write_8(ioport8_t *reg, uint8_t val) 234 335 { … … 270 371 } 271 372 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 301 373 /** @} 302 374 */ -
uspace/lib/c/generic/device/clock_dev.c
r8db09e4 r15d0046 27 27 */ 28 28 29 29 /** @addtogroup libc 30 30 * @{ 31 31 */ -
uspace/lib/c/generic/device/led_dev.c
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 201 1 Jan Vesely2 * Copyright (c) 2014 Martin Decky 3 3 * All rights reserved. 4 4 * … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvmouse 28 29 /** @addtogroup libc 29 30 * @{ 30 31 */ 31 32 /** @file 32 * @brief ps/2 mouse driver.33 33 */ 34 34 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> 37 40 38 #include <libarch/types.h> 39 #include <async.h> 41 int 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 } 40 55 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 /** @} 47 57 */ -
uspace/lib/c/generic/event.c
r8db09e4 r15d0046 38 38 39 39 #include <libc.h> 40 #include < event.h>40 #include <ipc/event.h> 41 41 42 /** Subscribe event notifications.42 /** Subscribe to event notifications. 43 43 * 44 44 * @param evno Event type to subscribe. … … 48 48 * 49 49 */ 50 int event_subscribe(event_type_t evno, sysarg_t imethod)50 int ipc_event_subscribe(event_type_t evno, sysarg_t imethod) 51 51 { 52 return __SYSCALL2(SYS_ EVENT_SUBSCRIBE, (sysarg_t) evno,52 return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno, 53 53 (sysarg_t) imethod); 54 54 } 55 55 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 */ 64 int ipc_event_task_subscribe(event_task_type_t evno, sysarg_t imethod) 57 65 { 58 return __SYSCALL2(SYS_ EVENT_SUBSCRIBE, (sysarg_t) evno,66 return __SYSCALL2(SYS_IPC_EVENT_SUBSCRIBE, (sysarg_t) evno, 59 67 (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 */ 77 int 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 */ 89 int ipc_event_task_unsubscribe(event_task_type_t evno) 90 { 91 return __SYSCALL1(SYS_IPC_EVENT_UNSUBSCRIBE, (sysarg_t) evno); 60 92 } 61 93 … … 67 99 * 68 100 */ 69 int event_unmask(event_type_t evno)101 int ipc_event_unmask(event_type_t evno) 70 102 { 71 return __SYSCALL1(SYS_ EVENT_UNMASK, (sysarg_t) evno);103 return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno); 72 104 } 73 105 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 */ 113 int ipc_event_task_unmask(event_task_type_t evno) 75 114 { 76 return __SYSCALL1(SYS_ EVENT_UNMASK, (sysarg_t) evno);115 return __SYSCALL1(SYS_IPC_EVENT_UNMASK, (sysarg_t) evno); 77 116 } 78 117 -
uspace/lib/c/generic/fibril.c
r8db09e4 r15d0046 59 59 static LIST_INITIALIZE(serialized_list); 60 60 static LIST_INITIALIZE(manager_list); 61 static LIST_INITIALIZE(fibril_list); 61 62 62 63 /** Number of threads that are executing a manager fibril. */ … … 116 117 117 118 fibril->waits_for = NULL; 119 list_append(&fibril->all_link, &fibril_list); 118 120 119 121 return fibril; … … 122 124 void fibril_teardown(fibril_t *fibril) 123 125 { 126 list_remove(&fibril->all_link); 124 127 tls_free(fibril->tcb); 125 128 free(fibril); -
uspace/lib/c/generic/fibril_synch.c
r8db09e4 r15d0046 448 448 int rc; 449 449 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; 460 474 } 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 476 482 return 0; 477 483 } … … 481 487 * @return New timer on success, @c NULL if out of memory. 482 488 */ 483 fibril_timer_t *fibril_timer_create( void)489 fibril_timer_t *fibril_timer_create(fibril_mutex_t *lock) 484 490 { 485 491 fid_t fid; … … 501 507 timer->fibril = fid; 502 508 timer->state = fts_not_set; 509 timer->lockp = (lock != NULL) ? lock : &timer->lock; 503 510 504 511 fibril_add_ready(fid); 505 506 512 return timer; 507 513 } … … 513 519 void fibril_timer_destroy(fibril_timer_t *timer) 514 520 { 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. */ 517 525 timer->state = fts_cleanup; 518 526 fibril_condvar_broadcast(&timer->cv); 519 fibril_mutex_unlock( &timer->lock);527 fibril_mutex_unlock(timer->lockp); 520 528 } 521 529 … … 533 541 fibril_timer_fun_t fun, void *arg) 534 542 { 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 */ 558 void 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); 536 563 timer->state = fts_active; 537 564 timer->delay = delay; … … 539 566 timer->arg = arg; 540 567 fibril_condvar_broadcast(&timer->cv); 541 fibril_mutex_unlock(&timer->lock);542 568 } 543 569 … … 557 583 fibril_timer_state_t old_state; 558 584 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 */ 604 fibril_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 560 613 old_state = timer->state; 561 614 timer->state = fts_not_set; … … 565 618 timer->arg = NULL; 566 619 fibril_condvar_broadcast(&timer->cv); 567 fibril_mutex_unlock(&timer->lock);568 620 569 621 return old_state; -
uspace/lib/c/generic/inet.c
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 34 34 #include <ipc/services.h> 35 35 #include <loc.h> 36 #include <stdlib.h> 36 37 37 38 static void inet_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 224 225 225 226 rc = inet_ev_ops->recv(&dgram); 227 free(dgram.data); 226 228 async_answer_0(iid, rc); 227 229 } -
uspace/lib/c/generic/io/asprintf.c
r8db09e4 r15d0046 76 76 * the newly allocated string. 77 77 * @fmt Format string. 78 * @args Variable argument list 79 * 80 * @return Number of characters printed or a negative error code. 81 * 82 */ 83 int 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. 78 106 * 79 107 * @return Number of characters printed or a negative error code. … … 84 112 va_list args; 85 113 va_start(args, fmt); 86 int ret = v printf_size(fmt, args);114 int ret = vasprintf(strp, fmt, args); 87 115 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 }98 116 99 117 return ret; -
uspace/lib/c/generic/io/chardev.c
r8db09e4 r15d0046 29 29 #include <errno.h> 30 30 #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> 41 33 42 34 ssize_t chardev_read(async_exch_t *exch, void *data, size_t size) … … 48 40 49 41 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, 51 43 &message[0], &message[1], &message[2], &message[3]); 52 44 if (ret > 0 && (size_t)ret <= size) … … 64 56 sysarg_t message[3] = { 0 }; 65 57 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, 67 59 message[0], message[1], message[2]); 68 60 } -
uspace/lib/c/generic/io/console.c
r8db09e4 r15d0046 75 75 bool console_kcon(void) 76 76 { 77 return __SYSCALL0(SYS_DEBUG_ ACTIVATE_CONSOLE);77 return __SYSCALL0(SYS_DEBUG_CONSOLE); 78 78 } 79 79 -
uspace/lib/c/generic/io/input.c
r8db09e4 r15d0046 80 80 } 81 81 82 int input_ yield(input_t *input)82 int input_activate(input_t *input) 83 83 { 84 84 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); 87 86 async_exchange_end(exch); 88 87 89 88 return rc; 90 89 } 91 90 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; 91 static 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 98 static 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); 100 103 } 101 104 … … 178 181 179 182 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; 180 189 case INPUT_EVENT_KEY: 181 190 input_ev_key(input, callid, &call); -
uspace/lib/c/generic/iplink.c
r8db09e4 r15d0046 171 171 } 172 172 173 int 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 173 196 int iplink_addr_add(iplink_t *iplink, inet_addr_t *addr) 174 197 { … … 230 253 free(sdu.data); 231 254 async_answer_0(iid, rc); 255 } 256 257 static 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); 232 273 } 233 274 … … 249 290 iplink_ev_recv(iplink, callid, &call); 250 291 break; 292 case IPLINK_EV_CHANGE_ADDR: 293 iplink_ev_change_addr(iplink, callid, &call); 251 294 default: 252 295 async_answer_0(callid, ENOTSUP); -
uspace/lib/c/generic/iplink_srv.c
r8db09e4 r15d0046 81 81 } 82 82 83 static 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 83 110 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid, 84 111 ipc_call_t *icall) … … 252 279 iplink_get_mac48_srv(srv, callid, &call); 253 280 break; 281 case IPLINK_SET_MAC48: 282 iplink_set_mac48_srv(srv, callid, &call); 283 break; 254 284 case IPLINK_SEND: 255 285 iplink_send_srv(srv, callid, &call); … … 300 330 } 301 331 332 int 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 302 358 /** @} 303 359 */ -
uspace/lib/c/generic/irq.c
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 20 05 Jakub Jermar2 * Copyright (c) 2014 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mips64mm29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 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> 43 37 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 */ 48 int ipc_irq_subscribe(int inr, int devno, sysarg_t method, 49 const irq_code_t *ucode) 46 50 { 47 as_operations = &as_ht_operations;48 asid_fifo_init();51 return __SYSCALL4(SYS_IPC_IRQ_SUBSCRIBE, inr, devno, method, 52 (sysarg_t) ucode); 49 53 } 50 54 51 /** Install address space.55 /** Unsubscribe from IRQ notification. 52 56 * 53 * Install ASID. 57 * @param inr IRQ number. 58 * @param devno Device number of the device generating inr. 54 59 * 55 * @ param as Address space structure.60 * @return Value returned by the kernel. 56 61 * 57 62 */ 58 void as_install_arch(as_t *as)63 int ipc_irq_unsubscribe(int inr, int devno) 59 64 { 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); 67 66 } 68 67 -
uspace/lib/c/generic/stacktrace.c
r8db09e4 r15d0046 42 42 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); 43 43 44 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 44 static stacktrace_ops_t basic_ops = { 45 .read_uintptr = stacktrace_read_uintptr 46 }; 47 48 void stacktrace_print_generic(stacktrace_ops_t *ops, void *arg, uintptr_t fp, 49 uintptr_t pc) 45 50 { 46 51 stacktrace_t st; 47 52 uintptr_t nfp; 53 int rc; 48 54 49 st.op_arg = NULL;50 st. read_uintptr = stacktrace_read_uintptr;55 st.op_arg = arg; 56 st.ops = ops; 51 57 52 58 while (stacktrace_fp_valid(&st, fp)) { 53 59 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; 56 66 fp = nfp; 57 67 } 68 } 69 70 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 71 { 72 stacktrace_print_generic(&basic_ops, NULL, fp, pc); 58 73 } 59 74 -
uspace/lib/c/generic/str.c
r8db09e4 r15d0046 1360 1360 } 1361 1361 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 */ 1374 char *str_tok(char *s, const char *delim, char **next) 1370 1375 { 1371 1376 char *start, *end; 1372 1377 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; 1375 1385 1376 1386 /* 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]; 1379 1391 1380 1392 /* 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) 1386 1401 return NULL; /* No more tokens. */ 1387 }1388 1402 1389 1403 /* Overwrite delimiter with NULL terminator. */ -
uspace/lib/c/generic/task.c
r8db09e4 r15d0046 2 2 * Copyright (c) 2006 Jakub Jermar 3 3 * Copyright (c) 2008 Jiri Svoboda 4 * Copyright (c) 2014 Martin Sucha 4 5 * All rights reserved. 5 6 * … … 94 95 * 95 96 * @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. 96 99 * @param path Pathname of the binary to execute. 97 100 * @param argv Command-line arguments. … … 100 103 * 101 104 */ 102 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 105 int task_spawnv(task_id_t *id, task_wait_t *wait, const char *path, 106 const char *const args[]) 103 107 { 104 108 /* Send default files */ … … 125 129 files[3] = NULL; 126 130 127 return task_spawnvf(id, path, args, files);131 return task_spawnvf(id, wait, path, args, files); 128 132 } 129 133 … … 135 139 * 136 140 * @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. 137 143 * @param path Pathname of the binary to execute. 138 144 * @param argv Command-line arguments. … … 142 148 * 143 149 */ 144 int task_spawnvf(task_id_t *id, const char *path, const char *const args[],145 int *const files[])150 int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 151 const char *const args[], int *const files[]) 146 152 { 147 153 /* Connect to a program loader. */ … … 150 156 return EREFUSED; 151 157 158 bool wait_initialized = false; 159 152 160 /* Get task ID. */ 153 161 task_id_t task_id; … … 181 189 goto error; 182 190 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 183 199 /* Run it. */ 184 200 rc = loader_run(ldr); … … 193 209 194 210 error: 211 if (wait_initialized) 212 task_cancel_wait(wait); 213 195 214 /* Error exit */ 196 215 loader_abort(ldr); … … 204 223 * 205 224 * @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. 206 227 * @param path Pathname of the binary to execute. 207 228 * @param cnt Number of arguments. … … 211 232 * 212 233 */ 213 int task_spawn(task_id_t *task_id, const char *path, int cnt, va_list ap) 234 int task_spawn(task_id_t *task_id, task_wait_t *wait, const char *path, 235 int cnt, va_list ap) 214 236 { 215 237 /* Allocate argument list. */ … … 227 249 228 250 /* Spawn task. */ 229 int rc = task_spawnv(task_id, path, arglist);251 int rc = task_spawnv(task_id, wait, path, arglist); 230 252 231 253 /* Free argument list. */ … … 240 262 * 241 263 * @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. 242 266 * @param path Pathname of the binary to execute. 243 267 * @param ... Command-line arguments. … … 246 270 * 247 271 */ 248 int task_spawnl(task_id_t *task_id, const char *path, ...)272 int task_spawnl(task_id_t *task_id, task_wait_t *wait, const char *path, ...) 249 273 { 250 274 /* Count the number of arguments. */ … … 262 286 263 287 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); 265 289 va_end(ap); 266 290 … … 268 292 } 269 293 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 */ 305 int 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 */ 324 void 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 */ 342 int task_wait(task_wait_t *wait, task_exit_t *texit, int *retval) 271 343 { 272 344 assert(texit); 273 345 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 */ 372 int 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); 285 380 } 286 381 -
uspace/lib/c/generic/time.c
r8db09e4 r15d0046 555 555 } 556 556 557 void *addr ;557 void *addr = AS_AREA_ANY; 558 558 rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE, 559 559 &addr); -
uspace/lib/c/include/adt/list.h
r8db09e4 r15d0046 39 39 #include <assert.h> 40 40 #include <stdbool.h> 41 #include < unistd.h>41 #include <stddef.h> 42 42 43 43 /** Doubly linked list link. */ -
uspace/lib/c/include/async.h
r8db09e4 r15d0046 45 45 #include <atomic.h> 46 46 #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> 48 50 49 51 typedef ipc_callid_t aid_t; … … 62 64 typedef void (*async_client_conn_t)(ipc_callid_t, ipc_call_t *, void *); 63 65 64 /** Interrupt handler */ 65 typedef void (*async_interrupt_handler_t)(ipc_callid_t, ipc_call_t *); 66 /** Notification handler */ 67 typedef void (*async_notification_handler_t)(ipc_callid_t, ipc_call_t *, 68 void *); 66 69 67 70 /** Exchange management style … … 155 158 156 159 extern 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); 160 extern void async_set_notification_handler_stack_size(size_t); 161 162 extern int async_irq_subscribe(int, int, async_notification_handler_t, void *, 163 const irq_code_t *); 164 extern int async_irq_unsubscribe(int, int); 165 166 extern int async_event_subscribe(event_type_t, async_notification_handler_t, 167 void *); 168 extern int async_event_task_subscribe(event_task_type_t, 169 async_notification_handler_t, void *); 170 extern int async_event_unsubscribe(event_type_t); 171 extern int async_event_task_unsubscribe(event_task_type_t); 172 extern int async_event_unmask(event_type_t); 173 extern int async_event_task_unmask(event_task_type_t); 159 174 160 175 /* -
uspace/lib/c/include/bd.h
r8db09e4 r15d0046 48 48 extern int bd_read_toc(bd_t *, uint8_t, void *, size_t); 49 49 extern int bd_write_blocks(bd_t *, aoff64_t, size_t, const void *, size_t); 50 extern int bd_sync_cache(bd_t *, aoff64_t, size_t); 50 51 extern int bd_get_block_size(bd_t *, size_t *); 51 52 extern int bd_get_num_blocks(bd_t *, aoff64_t *); -
uspace/lib/c/include/bd_srv.h
r8db09e4 r15d0046 62 62 int (*read_blocks)(bd_srv_t *, aoff64_t, size_t, void *, size_t); 63 63 int (*read_toc)(bd_srv_t *, uint8_t, void *, size_t); 64 int (*sync_cache)(bd_srv_t *, aoff64_t, size_t); 64 65 int (*write_blocks)(bd_srv_t *, aoff64_t, size_t, const void *, size_t); 65 66 int (*get_block_size)(bd_srv_t *, size_t *); -
uspace/lib/c/include/ddi.h
r8db09e4 r15d0046 51 51 52 52 extern int physmem_map(uintptr_t, size_t, unsigned int, void **); 53 extern int physmem_unmap(void *); 53 54 54 55 extern int dmamem_map(void *, size_t, unsigned int, unsigned int, uintptr_t *); … … 61 62 extern int pio_enable_resource(pio_window_t *, hw_resource_t *, void **); 62 63 extern int pio_enable(void *, size_t, void **); 64 extern int pio_disable(void *, size_t); 63 65 64 66 typedef void (*trace_fnc)(const volatile void *place, uint32_t val, … … 130 132 } 131 133 132 extern int irq_register(int, int, int, const irq_code_t *);133 extern int irq_unregister(int, int);134 135 134 #endif 136 135 -
uspace/lib/c/include/fibril.h
r8db09e4 r15d0046 67 67 typedef struct fibril { 68 68 link_t link; 69 link_t all_link; 69 70 context_t ctx; 70 71 void *stack; -
uspace/lib/c/include/fibril_synch.h
r8db09e4 r15d0046 116 116 /** Timer has fired and has not been cleared since */ 117 117 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 120 122 } fibril_timer_state_t; 121 123 … … 129 131 typedef struct { 130 132 fibril_mutex_t lock; 133 fibril_mutex_t *lockp; 131 134 fibril_condvar_t cv; 132 135 fid_t fibril; 133 136 fibril_timer_state_t state; 137 bool handler_running; 134 138 135 139 suseconds_t delay; … … 160 164 extern void fibril_condvar_broadcast(fibril_condvar_t *); 161 165 162 extern fibril_timer_t *fibril_timer_create( void);166 extern fibril_timer_t *fibril_timer_create(fibril_mutex_t *); 163 167 extern void fibril_timer_destroy(fibril_timer_t *); 164 168 extern void fibril_timer_set(fibril_timer_t *, suseconds_t, fibril_timer_fun_t, 165 169 void *); 170 extern void fibril_timer_set_locked(fibril_timer_t *, suseconds_t, 171 fibril_timer_fun_t, void *); 166 172 extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *); 173 extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *); 167 174 168 175 #endif -
uspace/lib/c/include/inet/iplink.h
r8db09e4 r15d0046 78 78 typedef struct iplink_ev_ops { 79 79 int (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t); 80 int (*change_addr)(iplink_t *, addr48_t); 80 81 } iplink_ev_ops_t; 81 82 … … 88 89 extern int iplink_get_mtu(iplink_t *, size_t *); 89 90 extern int iplink_get_mac48(iplink_t *, addr48_t *); 91 extern int iplink_set_mac48(iplink_t *, addr48_t); 90 92 91 93 #endif -
uspace/lib/c/include/inet/iplink_srv.h
r8db09e4 r15d0046 59 59 int (*get_mtu)(iplink_srv_t *, size_t *); 60 60 int (*get_mac48)(iplink_srv_t *, addr48_t *); 61 int (*set_mac48)(iplink_srv_t *, addr48_t *); 61 62 int (*addr_add)(iplink_srv_t *, inet_addr_t *); 62 63 int (*addr_remove)(iplink_srv_t *, inet_addr_t *); … … 67 68 extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *); 68 69 extern int iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t); 70 extern int iplink_ev_change_addr(iplink_srv_t *, addr48_t *); 69 71 70 72 #endif -
uspace/lib/c/include/io/chardev.h
r8db09e4 r15d0046 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvkbd28 /** @addtogroup libc 29 29 * @{ 30 30 */ 31 /** @file32 * @brief ps/2 mouse driver.33 */34 31 35 #ifndef _CHARDEV_H_36 #define _CHARDEV_H_32 #ifndef LIBC_IO_CHARDEV_H_ 33 #define LIBC_IO_CHARDEV_H_ 37 34 38 35 #include <libarch/types.h> -
uspace/lib/c/include/io/input.h
r8db09e4 r15d0046 49 49 50 50 typedef struct input_ev_ops { 51 int (*active)(input_t *); 52 int (*deactive)(input_t *); 51 53 int (*key)(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t); 52 54 int (*move)(input_t *, int, int); … … 57 59 extern int input_open(async_sess_t *, input_ev_ops_t *, void *, input_t **); 58 60 extern void input_close(input_t *); 59 extern int input_yield(input_t *); 60 extern int input_reclaim(input_t *); 61 extern int input_activate(input_t *); 61 62 62 63 #endif -
uspace/lib/c/include/io/pixelmap.h
r8db09e4 r15d0046 1 1 /* 2 2 * Copyright (c) 2011 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 40 41 #include <unistd.h> 41 42 #include <io/pixel.h> 43 44 /* Defines how a pixel outside of pixmap rectangle shall be treated */ 45 typedef 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; 42 60 43 61 typedef struct { … … 86 104 } 87 105 106 static 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 88 150 #endif 89 151 -
uspace/lib/c/include/ipc/bd.h
r8db09e4 r15d0046 42 42 BD_GET_NUM_BLOCKS, 43 43 BD_READ_BLOCKS, 44 BD_SYNC_CACHE, 44 45 BD_WRITE_BLOCKS, 45 46 BD_READ_TOC -
uspace/lib/c/include/ipc/chardev.h
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 20 03-2004 Jakub Jermar2 * Copyright (c) 2014 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mips6429 /** @addtogroup libcipc 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief Character device interface. 33 34 */ 34 35 35 #ifndef KERN_mips64_CPU_H_36 #define KERN_mips64_CPU_H_36 #ifndef LIBC_IPC_CHARDEV_H_ 37 #define LIBC_IPC_CHARDEV_H_ 37 38 38 #include <typedefs.h> 39 #include <arch/asm.h> 39 #include <ipc/common.h> 40 40 41 typedef struct{42 uint32_t imp_num;43 uint32_t rev_num;44 } c pu_arch_t;41 typedef enum { 42 CHARDEV_READ = IPC_FIRST_USER_METHOD, 43 CHARDEV_WRITE 44 } chardev_request_t; 45 45 46 46 #endif -
uspace/lib/c/include/ipc/common.h
r8db09e4 r15d0046 39 39 #include <abi/ipc/ipc.h> 40 40 #include <atomic.h> 41 #include < task.h>41 #include <abi/proc/task.h> 42 42 43 43 #define IPC_FLAG_BLOCKING 0x01 -
uspace/lib/c/include/ipc/dev_iface.h
r8db09e4 r15d0046 41 41 CHAR_DEV_IFACE, 42 42 43 /** Graphic device interface */44 GRAPH_DEV_IFACE,45 46 43 /** Audio device mixer interface */ 47 44 AUDIO_MIXER_IFACE, … … 64 61 /** Interface provided by Real Time Clock devices */ 65 62 CLOCK_DEV_IFACE, 63 64 /** Interface provided by LED devices */ 65 LED_DEV_IFACE, 66 66 67 67 /** Interface provided by battery powered devices */ -
uspace/lib/c/include/ipc/event.h
r8db09e4 r15d0046 33 33 */ 34 34 35 #ifndef LIBC_ EVENT_H_36 #define LIBC_ EVENT_H_35 #ifndef LIBC_IPC_EVENT_H_ 36 #define LIBC_IPC_EVENT_H_ 37 37 38 38 #include <abi/ipc/event.h> 39 39 #include <libarch/types.h> 40 40 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); 41 extern int ipc_event_subscribe(event_type_t, sysarg_t); 42 extern int ipc_event_task_subscribe(event_task_type_t, sysarg_t); 43 extern int ipc_event_unsubscribe(event_type_t); 44 extern int ipc_event_task_unsubscribe(event_task_type_t); 45 extern int ipc_event_unmask(event_type_t); 46 extern int ipc_event_task_unmask(event_task_type_t); 45 47 46 48 #endif -
uspace/lib/c/include/ipc/input.h
r8db09e4 r15d0046 39 39 40 40 typedef enum { 41 INPUT_YIELD = IPC_FIRST_USER_METHOD, 42 INPUT_RECLAIM 41 INPUT_ACTIVATE = IPC_FIRST_USER_METHOD 43 42 } input_request_t; 44 43 45 44 typedef 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, 47 48 INPUT_EVENT_MOVE, 48 49 INPUT_EVENT_ABS_MOVE, -
uspace/lib/c/include/ipc/ipc.h
r8db09e4 r15d0046 44 44 #include <abi/ipc/methods.h> 45 45 #include <abi/synch.h> 46 #include < task.h>46 #include <abi/proc/task.h> 47 47 48 48 typedef void (*ipc_async_callback_t)(void *, int, ipc_call_t *); -
uspace/lib/c/include/ipc/iplink.h
r8db09e4 r15d0046 41 41 IPLINK_GET_MTU = IPC_FIRST_USER_METHOD, 42 42 IPLINK_GET_MAC48, 43 IPLINK_SET_MAC48, 43 44 IPLINK_SEND, 44 45 IPLINK_SEND6, … … 48 49 49 50 typedef enum { 50 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD 51 IPLINK_EV_RECV = IPC_FIRST_USER_METHOD, 52 IPLINK_EV_CHANGE_ADDR, 51 53 } iplink_event_t; 52 54 -
uspace/lib/c/include/ipc/irc.h
r8db09e4 r15d0046 33 33 */ 34 34 35 #ifndef LIBC_I RC_H_36 #define LIBC_I RC_H_35 #ifndef LIBC_IPC_IRC_H_ 36 #define LIBC_IPC_IRC_H_ 37 37 38 38 #include <ipc/common.h> -
uspace/lib/c/include/ipc/irq.h
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 20 03-2004 Jakub Jermar2 * Copyright (c) 2014 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mips6429 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_mips64_CACHE_H_36 #define KERN_mips64_CACHE_H_35 #ifndef LIBC_IPC_IRQ_H_ 36 #define LIBC_IPC_IRQ_H_ 37 37 38 #include <arch/exception.h> 38 #include <sys/types.h> 39 #include <abi/ddi/irq.h> 39 40 40 extern void cache_error(istate_t *); 41 extern int ipc_irq_subscribe(int, int, sysarg_t, const irq_code_t *); 42 extern int ipc_irq_unsubscribe(int, int); 41 43 42 44 #endif -
uspace/lib/c/include/irc.h
r8db09e4 r15d0046 1 1 /* 2 * Copyright (c) 201 1 Petr Koupy2 * Copyright (c) 2014 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 33 33 */ 34 34 35 #ifndef LIBC_ DEVICE_GRAPH_DEV_H_36 #define LIBC_ DEVICE_GRAPH_DEV_H_35 #ifndef LIBC_IRC_H_ 36 #define LIBC_IRC_H_ 37 37 38 #include <async.h> 39 40 extern int graph_dev_connect(async_sess_t *); 38 extern int irc_enable_interrupt(int); 39 extern int irc_disable_interrupt(int); 41 40 42 41 #endif -
uspace/lib/c/include/loader/loader.h
r8db09e4 r15d0046 37 37 #define LIBC_LOADER_H_ 38 38 39 #include < task.h>39 #include <abi/proc/task.h> 40 40 41 41 /** Forward declararion */ -
uspace/lib/c/include/stacktrace.h
r8db09e4 r15d0046 41 41 42 42 typedef struct { 43 int (*read_uintptr)(void *, uintptr_t, uintptr_t *); 44 } stacktrace_ops_t; 45 46 typedef struct { 43 47 void *op_arg; 44 int (*read_uintptr)(void *, uintptr_t, uintptr_t *);48 stacktrace_ops_t *ops; 45 49 } stacktrace_t; 46 50 47 51 extern void stacktrace_print(void); 48 52 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t); 53 extern void stacktrace_print_generic(stacktrace_ops_t *, void *, uintptr_t, 54 uintptr_t); 49 55 50 56 /* -
uspace/lib/c/include/stddef.h
r8db09e4 r15d0046 38 38 #include <sys/types.h> 39 39 40 #ifndef NULL 41 #define NULL ((void *) 0) 42 #endif 43 44 40 45 #endif 41 46 -
uspace/lib/c/include/stdio.h
r8db09e4 r15d0046 120 120 extern int snprintf(char *, size_t , const char *, ...) 121 121 PRINTF_ATTRIBUTE(3, 4); 122 extern int vasprintf(char **, const char *, va_list); 122 123 extern int asprintf(char **, const char *, ...) 123 124 PRINTF_ATTRIBUTE(2, 3); -
uspace/lib/c/include/str.h
r8db09e4 r15d0046 109 109 extern char *str_ndup(const char *, size_t max_size); 110 110 111 extern char *str_tok(char *, const char *, char **); 112 111 113 extern int str_uint8_t(const char *, const char **, unsigned int, bool, 112 114 uint8_t *); … … 132 134 extern unsigned long strtoul(const char *, char **, int); 133 135 134 extern char * strtok_r(char *, const char *, char **);135 extern char * strtok(char *, const char *);136 137 136 #endif 138 137 -
uspace/lib/c/include/task.h
r8db09e4 r15d0046 39 39 #include <abi/proc/task.h> 40 40 #include <stdarg.h> 41 #include <async.h> 42 #include <types/task.h> 41 43 42 typedef enum { 43 TASK_EXIT_NORMAL, 44 TASK_EXIT_UNEXPECTED 45 } task_exit_t; 44 typedef struct { 45 ipc_call_t result; 46 aid_t aid; 47 } task_wait_t; 48 49 struct _TASK; 50 typedef struct _TASK task_t; 46 51 47 52 extern task_id_t task_get_id(void); … … 49 54 extern int task_kill(task_id_t); 50 55 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, ...); 56 extern int task_spawnv(task_id_t *, task_wait_t *, const char *path, 57 const char *const []); 58 extern int task_spawnvf(task_id_t *, task_wait_t *, const char *path, 59 const char *const [], int *const []); 60 extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int, 61 va_list ap); 62 extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...); 56 63 57 extern int task_wait(task_id_t id, task_exit_t *, int *); 64 extern int task_setup_wait(task_id_t, task_wait_t *); 65 extern void task_cancel_wait(task_wait_t *); 66 extern int task_wait(task_wait_t *, task_exit_t *, int *); 67 extern int task_wait_task_id(task_id_t, task_exit_t *, int *); 58 68 extern int task_retval(int); 59 69 -
uspace/lib/c/include/types/task.h
r8db09e4 r15d0046 27 27 */ 28 28 29 /** @addtogroup mips64proc29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_mips64_TASK_H_36 #define KERN_mips64_TASK_H_35 #ifndef LIBC_TYPES_TASK_H_ 36 #define LIBC_TYPES_TASK_H_ 37 37 38 typedef struct { 39 } task_arch_t; 40 41 #define task_create_arch(task) 42 #define task_destroy_arch(task) 38 typedef enum { 39 TASK_EXIT_NORMAL, 40 TASK_EXIT_UNEXPECTED 41 } task_exit_t; 43 42 44 43 #endif
Note:
See TracChangeset
for help on using the changeset viewer.