Changeset 925a21e in mainline for uspace/lib/c
- Timestamp:
- 2011-09-24T14:20:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bf76c1
- Parents:
- 867e2555 (diff), 1ab4aca (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:
-
- 42 added
- 5 deleted
- 96 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r867e2555 r925a21e 31 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 32 33 INCLUDE_KERNEL = include/kernel 34 INCLUDE_ARCH = include/arch 33 INCLUDE_ABI = include/abi 35 34 INCLUDE_LIBARCH = include/libarch 36 35 … … 47 46 $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld 48 47 49 PRE_DEPEND = $(INCLUDE_ KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH)48 PRE_DEPEND = $(INCLUDE_ABI) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) 50 49 EXTRA_OUTPUT = $(LINKER_SCRIPTS) 51 EXTRA_CLEAN = $(INCLUDE_ KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPTS)50 EXTRA_CLEAN = $(INCLUDE_ABI) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPTS) 52 51 LIBRARY = libc 53 52 SLIBRARY = libc.so.0.0 … … 64 63 generic/as.c \ 65 64 generic/cap.c \ 65 generic/cfg.c \ 66 66 generic/clipboard.c \ 67 generic/devmap.c \68 67 generic/devman.c \ 69 68 generic/device/hw_res.c \ … … 72 71 generic/event.c \ 73 72 generic/errno.c \ 73 generic/loc.c \ 74 74 generic/mem.c \ 75 75 generic/str.c \ … … 94 94 generic/io/printf_core.c \ 95 95 generic/io/console.c \ 96 generic/io/screenbuffer.c \97 96 generic/malloc.c \ 98 97 generic/sysinfo.c \ 99 98 generic/ipc.c \ 100 99 generic/ns.c \ 101 generic/ns_obsolete.c \102 100 generic/async.c \ 103 generic/async_obsolete.c \104 101 generic/loader.c \ 105 102 generic/getopt.c \ … … 144 141 include $(USPACE_PREFIX)/Makefile.common 145 142 146 $(INCLUDE_ARCH): $(INCLUDE_KERNEL) $(INCLUDE_KERNEL)/arch147 ln -sfn kernel/arch $@148 149 143 $(INCLUDE_LIBARCH): arch/$(UARCH)/include 150 144 ln -sfn ../$< $@ 151 145 152 $(INCLUDE_KERNEL)/arch: ../../../kernel/generic/include/arch $(INCLUDE_KERNEL) 153 154 $(INCLUDE_KERNEL): ../../../kernel/generic/include/ 146 $(INCLUDE_ABI): ../../../abi/include/ 155 147 ln -sfn ../$< $@ 156 148 -
uspace/lib/c/arch/abs32le/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Martin Decky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup debug 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_abs32le__ISTATE_H_ 36 #define LIBC_abs32le__ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/abs32le/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/abs32le/include/syscall.h
r867e2555 r925a21e 38 38 39 39 #include <sys/types.h> 40 #include < kernel/syscall/syscall.h>40 #include <abi/syscall.h> 41 41 42 42 #define __syscall0 __syscall -
uspace/lib/c/arch/abs32le/include/types.h
r867e2555 r925a21e 52 52 53 53 typedef uint32_t uintptr_t; 54 typedef int32_t intptr_t; 54 55 typedef uint32_t atomic_count_t; 55 56 typedef int32_t atomic_signed_t; -
uspace/lib/c/arch/amd64/include/atomic.h
r867e2555 r925a21e 44 44 static inline void atomic_inc(atomic_t *val) 45 45 { 46 #ifdef __PCC__ 47 asm volatile ( 48 "lock incq %0\n" 49 : "+m" (val->count) 50 ); 51 #else 46 52 asm volatile ( 47 53 "lock incq %[count]\n" 48 54 : [count] "+m" (val->count) 49 55 ); 56 #endif 50 57 } 51 58 52 59 static inline void atomic_dec(atomic_t *val) 53 60 { 61 #ifdef __PCC__ 62 asm volatile ( 63 "lock decq %0\n" 64 : "+m" (val->count) 65 ); 66 #else 54 67 asm volatile ( 55 68 "lock decq %[count]\n" 56 69 : [count] "+m" (val->count) 57 70 ); 71 #endif 58 72 } 59 73 … … 62 76 atomic_count_t r = 1; 63 77 78 #ifdef __PCC__ 79 asm volatile ( 80 "lock xaddq %1, %0\n" 81 : "+m" (val->count), 82 "+r" (r) 83 ); 84 #else 64 85 asm volatile ( 65 86 "lock xaddq %[r], %[count]\n" … … 67 88 [r] "+r" (r) 68 89 ); 90 #endif 69 91 70 92 return r; … … 75 97 atomic_count_t r = -1; 76 98 99 #ifdef __PCC__ 100 asm volatile ( 101 "lock xaddq %1, %0\n" 102 : "+m" (val->count), 103 "+r" (r) 104 ); 105 #else 77 106 asm volatile ( 78 107 "lock xaddq %[r], %[count]\n" … … 80 109 [r] "+r" (r) 81 110 ); 111 #endif 82 112 83 113 return r; -
uspace/lib/c/arch/amd64/include/elf_linux.h
r867e2555 r925a21e 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 33 33 */ 34 34 … … 39 39 #include <sys/types.h> 40 40 41 /** Linux kernel struct pt_regs structure. 42 * 43 * We need this to save register state to a core file in Linux format 44 * (readable by GDB configured for Linux target). 45 */ 41 46 typedef struct { 42 /* TODO */ 43 uint64_t pad[16]; 47 uint64_t r15; 48 uint64_t r14; 49 uint64_t r13; 50 uint64_t r12; 51 uint64_t rbp; 52 uint64_t rbx; 53 uint64_t r11; 54 uint64_t r10; 55 uint64_t r9; 56 uint64_t r8; 57 uint64_t rax; 58 uint64_t rcx; 59 uint64_t rdx; 60 uint64_t rsi; 61 uint64_t rdi; 62 uint64_t old_rax; 63 uint64_t rip; 64 uint64_t cs; 65 uint64_t rflags; 66 uint64_t rsp; 67 uint64_t ss; 44 68 } elf_regs_t; 45 69 70 /** Convert istate_t to elf_regs_t. */ 46 71 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 47 72 { 48 /* TODO */ 49 (void) istate; (void) elf_regs; 73 elf_regs->r15 = istate->r15; 74 elf_regs->r14 = istate->r14; 75 elf_regs->r13 = istate->r13; 76 elf_regs->r12 = istate->r12; 77 elf_regs->rbp = istate->rbp; 78 elf_regs->rbx = istate->rbx; 79 elf_regs->r11 = istate->r11; 80 elf_regs->r10 = istate->r10; 81 elf_regs->r9 = istate->r9; 82 elf_regs->r8 = istate->r8; 83 elf_regs->rax = istate->rax; 84 elf_regs->rcx = istate->rcx; 85 elf_regs->rdx = istate->rdx; 86 elf_regs->rsi = istate->rsi; 87 elf_regs->rdi = istate->rdi; 88 elf_regs->rip = istate->rip; 89 elf_regs->cs = istate->cs; 90 elf_regs->rflags = istate->rflags; 91 elf_regs->rsp = istate->rsp; 92 elf_regs->ss = istate->ss; 50 93 } 51 94 -
uspace/lib/c/arch/amd64/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcamd64 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_amd64_ISTATE_H_ 36 #define LIBC_amd64_ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/amd64/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/amd64/include/types.h
r867e2555 r925a21e 52 52 53 53 typedef uint64_t uintptr_t; 54 typedef int64_t intptr_t; 54 55 typedef uint64_t atomic_count_t; 55 56 typedef int64_t atomic_signed_t; -
uspace/lib/c/arch/amd64/src/fibril.S
r867e2555 r925a21e 32 32 .global context_restore 33 33 34 #include < kernel/arch/context_offset.h>34 #include <libarch/context_offset.h> 35 35 36 36 ## Save current CPU context -
uspace/lib/c/arch/arm32/include/elf_linux.h
r867e2555 r925a21e 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 33 33 */ 34 34 … … 39 39 #include <sys/types.h> 40 40 41 /** Linux kernel struct pt_regs structure. 42 * 43 * We need this to save register state to a core file in Linux format 44 * (readable by GDB configured for Linux target). 45 */ 41 46 typedef struct { 42 /* TODO */ 43 uint32_t pad[16]; 47 uint32_t r0; 48 uint32_t r1; 49 uint32_t r2; 50 uint32_t r3; 51 uint32_t r4; 52 uint32_t r5; 53 uint32_t r6; 54 uint32_t r7; 55 uint32_t r8; 56 uint32_t r9; 57 uint32_t r10; 58 uint32_t fp; 59 uint32_t r12; 60 uint32_t sp; 61 uint32_t lr; 62 uint32_t pc; 63 uint32_t cpsr; 64 uint32_t old_r0; 44 65 } elf_regs_t; 45 66 67 /** Convert istate_t to elf_regs_t. */ 46 68 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 47 69 { 48 /* TODO */ 49 (void) istate; (void) elf_regs; 70 elf_regs->r0 = istate->r0; 71 elf_regs->r1 = istate->r1; 72 elf_regs->r2 = istate->r2; 73 elf_regs->r3 = istate->r3; 74 elf_regs->r4 = istate->r4; 75 elf_regs->r5 = istate->r5; 76 elf_regs->r6 = istate->r6; 77 elf_regs->r7 = istate->r7; 78 elf_regs->r8 = istate->r8; 79 elf_regs->r9 = istate->r9; 80 elf_regs->r10 = istate->r10; 81 82 elf_regs->fp = istate->fp; 83 elf_regs->r12 = istate->r12; 84 elf_regs->sp = istate->sp; 85 elf_regs->lr = istate->lr; 86 elf_regs->pc = istate->pc; 87 elf_regs->cpsr = istate->spsr; 88 elf_regs->old_r0 = 0; 50 89 } 51 90 -
uspace/lib/c/arch/arm32/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcarm32 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_arm32__ISTATE_H_ 36 #define LIBC_arm32__ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/arm32/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/arm32/include/types.h
r867e2555 r925a21e 53 53 54 54 typedef uint32_t uintptr_t; 55 typedef int32_t intptr_t; 55 56 typedef uint32_t atomic_count_t; 56 57 typedef int32_t atomic_signed_t; -
uspace/lib/c/arch/ia32/Makefile.common
r867e2555 r925a21e 28 28 29 29 CLANG_ARCH = i386 30 GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer 30 31 ifeq ($(PROCESSOR),i486) 32 GCC_CFLAGS += -march=i486 -fno-omit-frame-pointer 33 else 34 GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer 35 endif 31 36 32 37 ENDIANESS = LE -
uspace/lib/c/arch/ia32/Makefile.inc
r867e2555 r925a21e 28 28 29 29 ARCH_SOURCES = \ 30 arch/$(UARCH)/src/entry. s\30 arch/$(UARCH)/src/entry.S \ 31 31 arch/$(UARCH)/src/entryjmp.s \ 32 32 arch/$(UARCH)/src/thread_entry.s \ -
uspace/lib/c/arch/ia32/include/atomic.h
r867e2555 r925a21e 42 42 static inline void atomic_inc(atomic_t *val) 43 43 { 44 #ifdef __PCC__ 45 asm volatile ( 46 "lock incl %0\n" 47 : "+m" (val->count) 48 ); 49 #else 44 50 asm volatile ( 45 51 "lock incl %[count]\n" 46 52 : [count] "+m" (val->count) 47 53 ); 54 #endif 48 55 } 49 56 50 57 static inline void atomic_dec(atomic_t *val) 51 58 { 59 #ifdef __PCC__ 60 asm volatile ( 61 "lock decl %0\n" 62 : "+m" (val->count) 63 ); 64 #else 52 65 asm volatile ( 53 66 "lock decl %[count]\n" 54 67 : [count] "+m" (val->count) 55 68 ); 69 #endif 56 70 } 57 71 … … 60 74 atomic_count_t r = 1; 61 75 76 #ifdef __PCC__ 77 asm volatile ( 78 "lock xaddl %1, %0\n" 79 : "+m" (val->count), 80 "+r" (r) 81 ); 82 #else 62 83 asm volatile ( 63 84 "lock xaddl %[r], %[count]\n" … … 65 86 [r] "+r" (r) 66 87 ); 88 #endif 67 89 68 90 return r; … … 73 95 atomic_count_t r = -1; 74 96 97 #ifdef __PCC__ 98 asm volatile ( 99 "lock xaddl %1, %0\n" 100 : "+m" (val->count), 101 "+r" (r) 102 ); 103 #else 75 104 asm volatile ( 76 105 "lock xaddl %[r], %[count]\n" … … 78 107 [r] "+r" (r) 79 108 ); 109 #endif 80 110 81 111 return r; -
uspace/lib/c/arch/ia32/include/ddi.h
r867e2555 r925a21e 41 41 static inline uint8_t pio_read_8(ioport8_t *port) 42 42 { 43 uint8_t val; 44 45 asm volatile ( 46 "inb %w[port], %b[val]\n" 47 : [val] "=a" (val) 48 : [port] "d" (port) 49 ); 50 51 return val; 43 if (port < (ioport8_t *) IO_SPACE_BOUNDARY) { 44 uint8_t val; 45 46 asm volatile ( 47 "inb %w[port], %b[val]\n" 48 : [val] "=a" (val) 49 : [port] "d" (port) 50 ); 51 52 return val; 53 } else 54 return (uint8_t) *port; 52 55 } 53 56 54 57 static inline uint16_t pio_read_16(ioport16_t *port) 55 58 { 56 uint16_t val; 57 58 asm volatile ( 59 "inw %w[port], %w[val]\n" 60 : [val] "=a" (val) 61 : [port] "d" (port) 62 ); 63 64 return val; 59 if (port < (ioport16_t *) IO_SPACE_BOUNDARY) { 60 uint16_t val; 61 62 asm volatile ( 63 "inw %w[port], %w[val]\n" 64 : [val] "=a" (val) 65 : [port] "d" (port) 66 ); 67 68 return val; 69 } else 70 return (uint16_t) *port; 65 71 } 66 72 67 73 static inline uint32_t pio_read_32(ioport32_t *port) 68 74 { 69 uint32_t val; 70 71 asm volatile ( 72 "inl %w[port], %[val]\n" 73 : [val] "=a" (val) 74 : [port] "d" (port) 75 ); 76 77 return val; 75 if (port < (ioport32_t *) IO_SPACE_BOUNDARY) { 76 uint32_t val; 77 78 asm volatile ( 79 "inl %w[port], %[val]\n" 80 : [val] "=a" (val) 81 : [port] "d" (port) 82 ); 83 84 return val; 85 } else 86 return (uint32_t) *port; 78 87 } 79 88 80 89 static inline void pio_write_8(ioport8_t *port, uint8_t val) 81 90 { 82 asm volatile ( 83 "outb %b[val], %w[port]\n" 84 :: [val] "a" (val), [port] "d" (port) 85 ); 91 if (port < (ioport8_t *) IO_SPACE_BOUNDARY) { 92 asm volatile ( 93 "outb %b[val], %w[port]\n" 94 :: [val] "a" (val), [port] "d" (port) 95 ); 96 } else 97 *port = val; 86 98 } 87 99 88 100 static inline void pio_write_16(ioport16_t *port, uint16_t val) 89 101 { 90 asm volatile ( 91 "outw %w[val], %w[port]\n" 92 :: [val] "a" (val), [port] "d" (port) 93 ); 102 if (port < (ioport16_t *) IO_SPACE_BOUNDARY) { 103 asm volatile ( 104 "outw %w[val], %w[port]\n" 105 :: [val] "a" (val), [port] "d" (port) 106 ); 107 } else 108 *port = val; 94 109 } 95 110 96 111 static inline void pio_write_32(ioport32_t *port, uint32_t val) 97 112 { 98 asm volatile ( 99 "outl %[val], %w[port]\n" 100 :: [val] "a" (val), [port] "d" (port) 101 ); 113 if (port < (ioport32_t *) IO_SPACE_BOUNDARY) { 114 asm volatile ( 115 "outl %[val], %w[port]\n" 116 :: [val] "a" (val), [port] "d" (port) 117 ); 118 } else 119 *port = val; 102 120 } 103 121 -
uspace/lib/c/arch/ia32/include/elf_linux.h
r867e2555 r925a21e 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 33 33 */ 34 34 … … 39 39 #include <sys/types.h> 40 40 41 /** Linux kernel struct pt_regs structure. 42 * 43 * We need this to save register state to a core file in Linux format 44 * (readable by GDB configured for Linux target). 45 */ 41 46 typedef struct { 42 47 uint32_t ebx; … … 59 64 } elf_regs_t; 60 65 66 /** Convert istate_t to elf_regs_t. */ 61 67 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 62 68 { -
uspace/lib/c/arch/ia32/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup debug 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_ia32__ISTATE_H_ 36 #define LIBC_ia32__ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/ia32/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/ia32/include/syscall.h
r867e2555 r925a21e 38 38 39 39 #include <sys/types.h> 40 #include < kernel/syscall/syscall.h>40 #include <abi/syscall.h> 41 41 42 42 #define __syscall0 __syscall_fast_func -
uspace/lib/c/arch/ia32/include/types.h
r867e2555 r925a21e 52 52 53 53 typedef uint32_t uintptr_t; 54 typedef int32_t intptr_t; 54 55 typedef uint32_t atomic_count_t; 55 56 typedef int32_t atomic_signed_t; -
uspace/lib/c/arch/ia32/src/entry.S
r867e2555 r925a21e 47 47 # Do not set %gs, it contains descriptor that can see TLS 48 48 49 #ifndef PROCESSOR_i486 49 50 # Detect the mechanism used for making syscalls 50 51 movl $(INTEL_CPUID_STANDARD), %eax … … 52 53 bt $(INTEL_SEP), %edx 53 54 jnc 0f 54 leal __syscall_fast_func, %eax 55 movl $__syscall_fast, (%eax) 56 0: 55 leal __syscall_fast_func, %eax 56 movl $__syscall_fast, (%eax) 57 0: 58 #endif 59 57 60 # 58 61 # Create the first stack frame. -
uspace/lib/c/arch/ia32/src/fibril.S
r867e2555 r925a21e 27 27 # 28 28 29 #include < kernel/arch/context_offset.h>29 #include <libarch/context_offset.h> 30 30 31 31 .text -
uspace/lib/c/arch/ia32/src/setjmp.S
r867e2555 r925a21e 27 27 # 28 28 29 #include < kernel/arch/context_offset.h>29 #include <libarch/context_offset.h> 30 30 31 31 .text -
uspace/lib/c/arch/ia64/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcsparc64 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_ia64_ISTATE_H_ 36 #define LIBC_ia64_ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/ia64/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/ia64/include/types.h
r867e2555 r925a21e 62 62 63 63 typedef uint64_t uintptr_t; 64 typedef int64_t intptr_t; 64 65 typedef uint64_t atomic_count_t; 65 66 typedef int64_t atomic_signed_t; -
uspace/lib/c/arch/mips32/include/elf_linux.h
r867e2555 r925a21e 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 33 33 */ 34 34 … … 39 39 #include <sys/types.h> 40 40 41 /** Linux kernel struct pt_regs structure. 42 * 43 * We need this to save register state to a core file in Linux format 44 * (readable by GDB configured for Linux target). 45 */ 41 46 typedef struct { 42 /* TODO */ 43 uint32_t pad[16]; 47 uint32_t pad0[6]; 48 49 uint32_t r0; 50 uint32_t r1; 51 uint32_t r2; 52 uint32_t r3; 53 uint32_t r4; 54 uint32_t r5; 55 uint32_t r6; 56 uint32_t r7; 57 uint32_t r8; 58 uint32_t r9; 59 uint32_t r10; 60 uint32_t r11; 61 uint32_t r12; 62 uint32_t r13; 63 uint32_t r14; 64 uint32_t r15; 65 uint32_t r16; 66 uint32_t r17; 67 uint32_t r18; 68 uint32_t r19; 69 uint32_t r20; 70 uint32_t r21; 71 uint32_t r22; 72 uint32_t r23; 73 uint32_t r24; 74 uint32_t r25; 75 uint32_t r26; 76 uint32_t r27; 77 uint32_t r28; 78 uint32_t r29; 79 uint32_t r30; 80 uint32_t r31; 81 82 uint32_t cp0_status; 83 uint32_t hi; 84 uint32_t lo; 85 uint32_t cp0_badvaddr; 86 uint32_t cp0_cause; 87 uint32_t cp0_epc; 44 88 } elf_regs_t; 45 89 90 /** Convert istate_t to elf_regs_t. */ 46 91 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 47 92 { 48 /* TODO */ 49 (void) istate; (void) elf_regs; 93 elf_regs->r1 = istate->at; 94 elf_regs->r2 = istate->v0; 95 elf_regs->r3 = istate->v1; 96 elf_regs->r4 = istate->a0; 97 elf_regs->r5 = istate->a1; 98 elf_regs->r6 = istate->a2; 99 elf_regs->r7 = istate->a3; 100 elf_regs->r8 = istate->t0; 101 elf_regs->r9 = istate->t1; 102 elf_regs->r10 = istate->t2; 103 elf_regs->r11 = istate->t3; 104 elf_regs->r12 = istate->t4; 105 elf_regs->r13 = istate->t5; 106 elf_regs->r14 = istate->t6; 107 elf_regs->r15 = istate->t7; 108 elf_regs->r16 = istate->s0; 109 elf_regs->r17 = istate->s1; 110 elf_regs->r18 = istate->s2; 111 elf_regs->r19 = istate->s3; 112 elf_regs->r20 = istate->s4; 113 elf_regs->r21 = istate->s5; 114 elf_regs->r22 = istate->s6; 115 elf_regs->r23 = istate->s7; 116 elf_regs->r24 = istate->t8; 117 elf_regs->r25 = istate->t9; 118 elf_regs->r26 = istate->kt0; 119 elf_regs->r27 = istate->kt1; 120 elf_regs->r28 = istate->gp; 121 elf_regs->r29 = istate->sp; 122 elf_regs->r30 = istate->s8; 123 elf_regs->r31 = istate->ra; 124 125 elf_regs->cp0_status = istate->status; 126 elf_regs->hi = istate->hi; 127 elf_regs->lo = istate->lo; 128 elf_regs->cp0_epc = istate->epc; 50 129 } 51 130 -
uspace/lib/c/arch/mips32/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcmips32 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_mips32__ISTATE_H_ 36 #define LIBC_mips32__ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/mips32/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/mips32/include/types.h
r867e2555 r925a21e 53 53 54 54 typedef uint32_t uintptr_t; 55 typedef int32_t intptr_t; 55 56 typedef uint32_t atomic_count_t; 56 57 typedef int32_t atomic_signed_t; -
uspace/lib/c/arch/mips32/src/fibril.S
r867e2555 r925a21e 32 32 .set noreorder 33 33 34 #include < arch/context_offset.h>34 #include <libarch/context_offset.h> 35 35 36 36 .global context_save -
uspace/lib/c/arch/mips64/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcmips64 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_mips64__ISTATE_H_ 36 #define LIBC_mips64__ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/mips64/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/mips64/include/types.h
r867e2555 r925a21e 53 53 54 54 typedef uint64_t uintptr_t; 55 typedef int64_t intptr_t; 55 56 typedef uint64_t atomic_count_t; 56 57 typedef int64_t atomic_signed_t; -
uspace/lib/c/arch/mips64/src/fibril.S
r867e2555 r925a21e 32 32 .set noreorder 33 33 34 #include < arch/context_offset.h>34 #include <libarch/context_offset.h> 35 35 36 36 .global context_save -
uspace/lib/c/arch/ppc32/include/elf_linux.h
r867e2555 r925a21e 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 33 33 */ 34 34 … … 39 39 #include <sys/types.h> 40 40 41 /** Linux kernel struct pt_regs structure. 42 * 43 * We need this to save register state to a core file in Linux format 44 * (readable by GDB configured for Linux target). 45 */ 41 46 typedef struct { 42 /* TODO */ 43 uint32_t pad[16]; 47 uint32_t r0; 48 uint32_t r1; 49 uint32_t r2; 50 uint32_t r3; 51 uint32_t r4; 52 uint32_t r5; 53 uint32_t r6; 54 uint32_t r7; 55 uint32_t r8; 56 uint32_t r9; 57 uint32_t r10; 58 uint32_t r11; 59 uint32_t r12; 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 nip; 81 uint32_t msr; 82 uint32_t old_r3; 83 uint32_t ctr; 84 uint32_t link; 85 uint32_t xer; 86 uint32_t ccr; 87 uint32_t mq; 88 uint32_t trap; 89 uint32_t dar; 90 uint32_t dsisr; 91 uint32_t result; 44 92 } elf_regs_t; 45 93 94 /** Convert istate_t to elf_regs_t. */ 46 95 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 47 96 { 48 /* TODO */ 49 (void) istate; (void) elf_regs; 97 elf_regs->r0 = istate->r0; 98 elf_regs->r1 = istate->sp; 99 elf_regs->r2 = istate->r2; 100 elf_regs->r3 = istate->r3; 101 elf_regs->r4 = istate->r4; 102 elf_regs->r5 = istate->r5; 103 elf_regs->r6 = istate->r6; 104 elf_regs->r7 = istate->r7; 105 elf_regs->r8 = istate->r8; 106 elf_regs->r9 = istate->r9; 107 elf_regs->r10 = istate->r10; 108 elf_regs->r11 = istate->r11; 109 elf_regs->r12 = istate->r12; 110 elf_regs->r13 = istate->r13; 111 elf_regs->r14 = istate->r14; 112 elf_regs->r15 = istate->r15; 113 elf_regs->r16 = istate->r16; 114 elf_regs->r17 = istate->r17; 115 elf_regs->r18 = istate->r18; 116 elf_regs->r19 = istate->r19; 117 elf_regs->r20 = istate->r20; 118 elf_regs->r21 = istate->r21; 119 elf_regs->r22 = istate->r22; 120 elf_regs->r23 = istate->r23; 121 elf_regs->r24 = istate->r24; 122 elf_regs->r25 = istate->r25; 123 elf_regs->r26 = istate->r26; 124 elf_regs->r27 = istate->r27; 125 elf_regs->r28 = istate->r28; 126 elf_regs->r29 = istate->r29; 127 elf_regs->r30 = istate->r30; 128 elf_regs->r31 = istate->r31; 129 130 elf_regs->ctr = istate->ctr; 131 elf_regs->link = istate->lr; 132 elf_regs->xer = istate->xer; 133 elf_regs->ccr = istate->cr; 134 elf_regs->dar = istate->dar; 50 135 } 51 136 -
uspace/lib/c/arch/ppc32/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcppc32 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_ppc32_ISTATE_H_ 36 #define LIBC_ppc32_ISTATE_H_ 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t r0; 46 uint32_t r2; 47 uint32_t r3; 48 uint32_t r4; 49 uint32_t r5; 50 uint32_t r6; 51 uint32_t r7; 52 uint32_t r8; 53 uint32_t r9; 54 uint32_t r10; 55 uint32_t r11; 56 uint32_t r13; 57 uint32_t r14; 58 uint32_t r15; 59 uint32_t r16; 60 uint32_t r17; 61 uint32_t r18; 62 uint32_t r19; 63 uint32_t r20; 64 uint32_t r21; 65 uint32_t r22; 66 uint32_t r23; 67 uint32_t r24; 68 uint32_t r25; 69 uint32_t r26; 70 uint32_t r27; 71 uint32_t r28; 72 uint32_t r29; 73 uint32_t r30; 74 uint32_t r31; 75 uint32_t cr; 76 uint32_t pc; 77 uint32_t srr1; 78 uint32_t lr; 79 uint32_t ctr; 80 uint32_t xer; 81 uint32_t dar; 82 uint32_t r12; 83 uint32_t sp; 84 } istate_t; 85 86 static inline uintptr_t istate_get_pc(istate_t *istate) 87 { 88 return istate->pc; 89 } 90 91 static inline uintptr_t istate_get_fp(istate_t *istate) 92 { 93 return istate->sp; 94 } 95 96 #endif 97 98 /** @} 99 */ 1 ../../../../../../kernel/arch/ppc32/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/ppc32/include/types.h
r867e2555 r925a21e 52 52 53 53 typedef uint32_t uintptr_t; 54 typedef int32_t intptr_t; 54 55 typedef uint32_t atomic_count_t; 55 56 typedef int32_t atomic_signed_t; -
uspace/lib/c/arch/ppc32/src/fibril.S
r867e2555 r925a21e 33 33 34 34 #include <libarch/regname.h> 35 #include < arch/context_offset.h>35 #include <libarch/context_offset.h> 36 36 37 37 context_save: -
uspace/lib/c/arch/sparc64/include/istate.h
-
Property mode
changed from
100644
to120000
r867e2555 r925a21e 1 /* 2 * Copyright (c) 2010 Jiri Svoboda 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libcsparc64 30 * @{ 31 */ 32 /** @file 33 */ 34 35 #ifndef LIBC_sparc64_ISTATE_H_ 36 #define LIBC_sparc64_ISTATE_H_ 37 38 #include <arch/istate.h> 39 40 #endif 41 42 /** @} 43 */ 1 ../../../../../../kernel/arch/sparc64/include/istate.h -
Property mode
changed from
-
uspace/lib/c/arch/sparc64/include/syscall.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include < kernel/syscall/syscall.h>39 #include <abi/syscall.h> 40 40 41 41 #define __syscall0 __syscall -
uspace/lib/c/arch/sparc64/include/types.h
r867e2555 r925a21e 52 52 53 53 typedef uint64_t uintptr_t; 54 typedef int64_t intptr_t; 54 55 typedef uint64_t atomic_count_t; 55 56 typedef int64_t atomic_signed_t; -
uspace/lib/c/arch/sparc64/src/fibril.S
r867e2555 r925a21e 27 27 # 28 28 29 #include < kernel/arch/context_offset.h>29 #include <libarch/context_offset.h> 30 30 31 .text 31 .text 32 32 33 33 .global context_save -
uspace/lib/c/generic/adt/hash_table.c
r867e2555 r925a21e 152 152 153 153 if (keys == h->max_keys) { 154 link_t *cur;155 156 154 /* 157 155 * All keys are known, hash_table_find() can be used to find the … … 159 157 */ 160 158 161 cur = hash_table_find(h, key);159 link_t *cur = hash_table_find(h, key); 162 160 if (cur) { 163 161 list_remove(cur); … … 174 172 hash_index_t chain; 175 173 for (chain = 0; chain < h->entries; chain++) { 176 link_t *cur; 177 178 for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head; 174 for (link_t *cur = h->entry[chain].head.next; 175 cur != &h->entry[chain].head; 179 176 cur = cur->next) { 180 177 if (h->op->compare(key, keys, cur)) { … … 193 190 } 194 191 195 /** Apply fu cntion to all items in hash table.192 /** Apply function to all items in hash table. 196 193 * 197 194 * @param h Hash table. -
uspace/lib/c/generic/adt/list.c
r867e2555 r925a21e 33 33 /** 34 34 * @file 35 * @brief Functions completing doubly linked circular list implementa ion.35 * @brief Functions completing doubly linked circular list implementation. 36 36 * 37 37 * This file contains some of the functions implementing doubly linked circular lists. … … 50 50 * @param list List to look in. 51 51 * 52 * @return true if link is contained in head, false otherwise.52 * @return true if link is contained in list, false otherwise. 53 53 * 54 54 */ -
uspace/lib/c/generic/as.c
r867e2555 r925a21e 123 123 * @retval ENOENT Mapping not found. 124 124 */ 125 int as_get_physical_mapping( void *address, uintptr_t *frame)125 int as_get_physical_mapping(const void *address, uintptr_t *frame) 126 126 { 127 127 uintptr_t tmp_frame; -
uspace/lib/c/generic/async.c
r867e2555 r925a21e 98 98 #include <ipc/ipc.h> 99 99 #include <async.h> 100 #include "private/async.h" 100 101 #undef LIBC_ASYNC_C_ 101 102 … … 107 108 #include <errno.h> 108 109 #include <sys/time.h> 109 #include < arch/barrier.h>110 #include <libarch/barrier.h> 110 111 #include <bool.h> 111 112 #include <malloc.h> 112 113 #include <mem.h> 113 114 #include <stdlib.h> 114 #include "private/async.h"115 #include <macros.h> 115 116 116 117 #define CLIENT_HASH_TABLE_BUCKETS 32 117 118 #define CONN_HASH_TABLE_BUCKETS 32 119 120 /** Session data */ 121 struct async_sess { 122 /** List of inactive exchanges */ 123 list_t exch_list; 124 125 /** Exchange management style */ 126 exch_mgmt_t mgmt; 127 128 /** Session identification */ 129 int phone; 130 131 /** First clone connection argument */ 132 sysarg_t arg1; 133 134 /** Second clone connection argument */ 135 sysarg_t arg2; 136 137 /** Third clone connection argument */ 138 sysarg_t arg3; 139 140 /** Exchange mutex */ 141 fibril_mutex_t mutex; 142 143 /** Number of opened exchanges */ 144 atomic_t refcnt; 145 146 /** Mutex for stateful connections */ 147 fibril_mutex_t remote_state_mtx; 148 149 /** Data for stateful connections */ 150 void *remote_state_data; 151 }; 152 153 /** Exchange data */ 154 struct async_exch { 155 /** Link into list of inactive exchanges */ 156 link_t sess_link; 157 158 /** Link into global list of inactive exchanges */ 159 link_t global_link; 160 161 /** Session pointer */ 162 async_sess_t *sess; 163 164 /** Exchange identification */ 165 int phone; 166 }; 118 167 119 168 /** Async framework global futex */ … … 134 183 } msg_t; 135 184 185 /** Message data */ 186 typedef struct { 187 awaiter_t wdata; 188 189 /** If reply was received. */ 190 bool done; 191 192 /** Pointer to where the answer data is stored. */ 193 ipc_call_t *dataptr; 194 195 sysarg_t retval; 196 } amsg_t; 197 136 198 /* Client connection data */ 137 199 typedef struct { 138 200 link_t link; 139 201 140 sysarg_t in_task_hash;202 task_id_t in_task_id; 141 203 atomic_t refcnt; 142 204 void *data; … … 150 212 link_t link; 151 213 152 /** Incoming client task hash. */153 sysarg_t in_task_hash;214 /** Incoming client task ID. */ 215 task_id_t in_task_id; 154 216 155 217 /** Incoming phone hash. */ … … 203 265 } 204 266 205 void *async_get_client_data(void)206 {207 assert(fibril_connection);208 return fibril_connection->client->data;209 }210 211 267 /** Default fibril function that gets called to handle new connection. 212 268 * … … 289 345 { 290 346 assert(key); 347 assert(keys == 2); 291 348 assert(item); 292 349 293 350 client_t *client = hash_table_get_instance(item, client_t, link); 294 return (key[0] == client->in_task_hash); 351 return (key[0] == LOWER32(client->in_task_id) && 352 (key[1] == UPPER32(client->in_task_id))); 295 353 } 296 354 … … 580 638 } 581 639 640 static client_t *async_client_get(task_id_t client_id, bool create) 641 { 642 unsigned long key[2] = { 643 LOWER32(client_id), 644 UPPER32(client_id), 645 }; 646 client_t *client = NULL; 647 648 futex_down(&async_futex); 649 link_t *lnk = hash_table_find(&client_hash_table, key); 650 if (lnk) { 651 client = hash_table_get_instance(lnk, client_t, link); 652 atomic_inc(&client->refcnt); 653 } else if (create) { 654 client = malloc(sizeof(client_t)); 655 if (client) { 656 client->in_task_id = client_id; 657 client->data = async_client_data_create(); 658 659 atomic_set(&client->refcnt, 1); 660 hash_table_insert(&client_hash_table, key, &client->link); 661 } 662 } 663 664 futex_up(&async_futex); 665 return client; 666 } 667 668 static void async_client_put(client_t *client) 669 { 670 bool destroy; 671 unsigned long key[2] = { 672 LOWER32(client->in_task_id), 673 UPPER32(client->in_task_id) 674 }; 675 676 futex_down(&async_futex); 677 678 if (atomic_predec(&client->refcnt) == 0) { 679 hash_table_remove(&client_hash_table, key, 2); 680 destroy = true; 681 } else 682 destroy = false; 683 684 futex_up(&async_futex); 685 686 if (destroy) { 687 if (client->data) 688 async_client_data_destroy(client->data); 689 690 free(client); 691 } 692 } 693 694 void *async_get_client_data(void) 695 { 696 assert(fibril_connection); 697 return fibril_connection->client->data; 698 } 699 700 void *async_get_client_data_by_id(task_id_t client_id) 701 { 702 client_t *client = async_client_get(client_id, false); 703 if (!client) 704 return NULL; 705 if (!client->data) { 706 async_client_put(client); 707 return NULL; 708 } 709 710 return client->data; 711 } 712 713 void async_put_client_data_by_id(task_id_t client_id) 714 { 715 client_t *client = async_client_get(client_id, false); 716 717 assert(client); 718 assert(client->data); 719 720 /* Drop the reference we got in async_get_client_data_by_hash(). */ 721 async_client_put(client); 722 723 /* Drop our own reference we got at the beginning of this function. */ 724 async_client_put(client); 725 } 726 582 727 /** Wrapper for client connection fibril. 583 728 * … … 598 743 */ 599 744 fibril_connection = (connection_t *) arg; 600 601 futex_down(&async_futex);602 745 603 746 /* … … 606 749 * hash in a new tracking structure. 607 750 */ 608 609 unsigned long key = fibril_connection->in_task_hash; 610 link_t *lnk = hash_table_find(&client_hash_table, &key); 611 612 client_t *client; 613 614 if (lnk) { 615 client = hash_table_get_instance(lnk, client_t, link); 616 atomic_inc(&client->refcnt); 617 } else { 618 client = malloc(sizeof(client_t)); 619 if (!client) { 620 ipc_answer_0(fibril_connection->callid, ENOMEM); 621 futex_up(&async_futex); 622 return 0; 623 } 624 625 client->in_task_hash = fibril_connection->in_task_hash; 626 client->data = async_client_data_create(); 627 628 atomic_set(&client->refcnt, 1); 629 hash_table_insert(&client_hash_table, &key, &client->link); 630 } 631 632 futex_up(&async_futex); 633 751 752 client_t *client = async_client_get(fibril_connection->in_task_id, true); 753 if (!client) { 754 ipc_answer_0(fibril_connection->callid, ENOMEM); 755 return 0; 756 } 757 634 758 fibril_connection->client = client; 635 759 … … 643 767 * Remove the reference for this client task connection. 644 768 */ 645 bool destroy; 646 647 futex_down(&async_futex); 648 649 if (atomic_predec(&client->refcnt) == 0) { 650 hash_table_remove(&client_hash_table, &key, 1); 651 destroy = true; 652 } else 653 destroy = false; 654 655 futex_up(&async_futex); 656 657 if (destroy) { 658 if (client->data) 659 async_client_data_destroy(client->data); 660 661 free(client); 662 } 769 async_client_put(client); 663 770 664 771 /* … … 666 773 */ 667 774 futex_down(&async_futex); 668 key = fibril_connection->in_phone_hash;775 unsigned long key = fibril_connection->in_phone_hash; 669 776 hash_table_remove(&conn_hash_table, &key, 1); 670 777 futex_up(&async_futex); … … 700 807 * particular fibrils. 701 808 * 702 * @param in_task_ hashIdentification of the incoming connection.809 * @param in_task_id Identification of the incoming connection. 703 810 * @param in_phone_hash Identification of the incoming connection. 704 811 * @param callid Hash of the opening IPC_M_CONNECT_ME_TO call. … … 714 821 * 715 822 */ 716 fid_t async_new_connection( sysarg_t in_task_hash, sysarg_t in_phone_hash,823 fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash, 717 824 ipc_callid_t callid, ipc_call_t *call, 718 825 async_client_conn_t cfibril, void *carg) … … 726 833 } 727 834 728 conn->in_task_ hash = in_task_hash;835 conn->in_task_id = in_task_id; 729 836 conn->in_phone_hash = in_phone_hash; 730 837 list_initialize(&conn->msg_queue); … … 785 892 case IPC_M_CONNECT_ME_TO: 786 893 /* Open new connection with fibril, etc. */ 787 async_new_connection(call->in_task_ hash, IPC_GET_ARG5(*call),894 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call), 788 895 callid, call, client_connection, NULL); 789 896 return; … … 933 1040 { 934 1041 if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 935 1, &client_hash_table_ops))1042 2, &client_hash_table_ops)) 936 1043 abort(); 937 1044 … … 949 1056 session_ns->arg2 = 0; 950 1057 session_ns->arg3 = 0; 1058 1059 fibril_mutex_initialize(&session_ns->remote_state_mtx); 1060 session_ns->remote_state_data = NULL; 951 1061 952 1062 list_initialize(&session_ns->exch_list); … … 1426 1536 return ENOENT; 1427 1537 1428 sysarg_t task_hash;1429 1538 sysarg_t phone_hash; 1430 int rc = async_req_3_5(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1431 NULL, NULL, NULL, &task_hash, &phone_hash); 1539 sysarg_t rc; 1540 1541 aid_t req; 1542 ipc_call_t answer; 1543 req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1544 &answer); 1545 async_wait_for(req, &rc); 1432 1546 if (rc != EOK) 1433 return rc; 1434 1547 return (int) rc; 1548 1549 phone_hash = IPC_GET_ARG5(answer); 1550 1435 1551 if (client_receiver != NULL) 1436 async_new_connection( task_hash, phone_hash, 0, NULL,1552 async_new_connection(answer.in_task_id, phone_hash, 0, NULL, 1437 1553 client_receiver, carg); 1438 1554 … … 1509 1625 sess->arg3 = 0; 1510 1626 1627 fibril_mutex_initialize(&sess->remote_state_mtx); 1628 sess->remote_state_data = NULL; 1629 1511 1630 list_initialize(&sess->exch_list); 1512 1631 fibril_mutex_initialize(&sess->mutex); … … 1590 1709 sess->arg3 = arg3; 1591 1710 1711 fibril_mutex_initialize(&sess->remote_state_mtx); 1712 sess->remote_state_data = NULL; 1713 1592 1714 list_initialize(&sess->exch_list); 1593 1715 fibril_mutex_initialize(&sess->mutex); … … 1595 1717 1596 1718 return sess; 1719 } 1720 1721 /** Set arguments for new connections. 1722 * 1723 * FIXME This is an ugly hack to work around the problem that parallel 1724 * exchanges are implemented using parallel connections. When we create 1725 * a callback session, the framework does not know arguments for the new 1726 * connections. 1727 * 1728 * The proper solution seems to be to implement parallel exchanges using 1729 * tagging. 1730 */ 1731 void async_sess_args_set(async_sess_t *sess, sysarg_t arg1, sysarg_t arg2, 1732 sysarg_t arg3) 1733 { 1734 sess->arg1 = arg1; 1735 sess->arg2 = arg2; 1736 sess->arg3 = arg3; 1597 1737 } 1598 1738 … … 1640 1780 sess->arg3 = arg3; 1641 1781 1782 fibril_mutex_initialize(&sess->remote_state_mtx); 1783 sess->remote_state_data = NULL; 1784 1642 1785 list_initialize(&sess->exch_list); 1643 1786 fibril_mutex_initialize(&sess->mutex); … … 1671 1814 sess->arg3 = 0; 1672 1815 1816 fibril_mutex_initialize(&sess->remote_state_mtx); 1817 sess->remote_state_data = NULL; 1818 1673 1819 list_initialize(&sess->exch_list); 1674 1820 fibril_mutex_initialize(&sess->mutex); … … 1692 1838 int async_hangup(async_sess_t *sess) 1693 1839 { 1840 async_exch_t *exch; 1841 1694 1842 assert(sess); 1695 1843 1696 1844 if (atomic_get(&sess->refcnt) > 0) 1697 1845 return EBUSY; 1846 1847 fibril_mutex_lock(&async_sess_mutex); 1698 1848 1699 1849 int rc = async_hangup_internal(sess->phone); 1700 1850 if (rc == EOK) 1701 1851 free(sess); 1852 1853 while (!list_empty(&sess->exch_list)) { 1854 exch = (async_exch_t *) 1855 list_get_instance(list_first(&sess->exch_list), 1856 async_exch_t, sess_link); 1857 1858 list_remove(&exch->sess_link); 1859 list_remove(&exch->global_link); 1860 async_hangup_internal(exch->phone); 1861 free(exch); 1862 } 1863 1864 fibril_mutex_unlock(&async_sess_mutex); 1702 1865 1703 1866 return rc; … … 2334 2497 sess->arg3 = 0; 2335 2498 2499 fibril_mutex_initialize(&sess->remote_state_mtx); 2500 sess->remote_state_data = NULL; 2501 2336 2502 list_initialize(&sess->exch_list); 2337 2503 fibril_mutex_initialize(&sess->mutex); … … 2380 2546 sess->arg3 = 0; 2381 2547 2548 fibril_mutex_initialize(&sess->remote_state_mtx); 2549 sess->remote_state_data = NULL; 2550 2382 2551 list_initialize(&sess->exch_list); 2383 2552 fibril_mutex_initialize(&sess->mutex); … … 2422 2591 sess->arg3 = 0; 2423 2592 2593 fibril_mutex_initialize(&sess->remote_state_mtx); 2594 sess->remote_state_data = NULL; 2595 2424 2596 list_initialize(&sess->exch_list); 2425 2597 fibril_mutex_initialize(&sess->mutex); … … 2429 2601 } 2430 2602 2603 int async_state_change_start(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2, 2604 sysarg_t arg3, async_exch_t *other_exch) 2605 { 2606 return async_req_5_0(exch, IPC_M_STATE_CHANGE_AUTHORIZE, 2607 arg1, arg2, arg3, 0, other_exch->phone); 2608 } 2609 2610 bool async_state_change_receive(ipc_callid_t *callid, sysarg_t *arg1, 2611 sysarg_t *arg2, sysarg_t *arg3) 2612 { 2613 assert(callid); 2614 2615 ipc_call_t call; 2616 *callid = async_get_call(&call); 2617 2618 if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE) 2619 return false; 2620 2621 if (arg1) 2622 *arg1 = IPC_GET_ARG1(call); 2623 if (arg2) 2624 *arg2 = IPC_GET_ARG2(call); 2625 if (arg3) 2626 *arg3 = IPC_GET_ARG3(call); 2627 2628 return true; 2629 } 2630 2631 int async_state_change_finalize(ipc_callid_t callid, async_exch_t *other_exch) 2632 { 2633 return ipc_answer_1(callid, EOK, other_exch->phone); 2634 } 2635 2636 /** Lock and get session remote state 2637 * 2638 * Lock and get the local replica of the remote state 2639 * in stateful sessions. The call should be paired 2640 * with async_remote_state_release*(). 2641 * 2642 * @param[in] sess Stateful session. 2643 * 2644 * @return Local replica of the remote state. 2645 * 2646 */ 2647 void *async_remote_state_acquire(async_sess_t *sess) 2648 { 2649 fibril_mutex_lock(&sess->remote_state_mtx); 2650 return sess->remote_state_data; 2651 } 2652 2653 /** Update the session remote state 2654 * 2655 * Update the local replica of the remote state 2656 * in stateful sessions. The remote state must 2657 * be already locked. 2658 * 2659 * @param[in] sess Stateful session. 2660 * @param[in] state New local replica of the remote state. 2661 * 2662 */ 2663 void async_remote_state_update(async_sess_t *sess, void *state) 2664 { 2665 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2666 sess->remote_state_data = state; 2667 } 2668 2669 /** Release the session remote state 2670 * 2671 * Unlock the local replica of the remote state 2672 * in stateful sessions. 2673 * 2674 * @param[in] sess Stateful session. 2675 * 2676 */ 2677 void async_remote_state_release(async_sess_t *sess) 2678 { 2679 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2680 2681 fibril_mutex_unlock(&sess->remote_state_mtx); 2682 } 2683 2684 /** Release the session remote state and end an exchange 2685 * 2686 * Unlock the local replica of the remote state 2687 * in stateful sessions. This is convenience function 2688 * which gets the session pointer from the exchange 2689 * and also ends the exchange. 2690 * 2691 * @param[in] exch Stateful session's exchange. 2692 * 2693 */ 2694 void async_remote_state_release_exchange(async_exch_t *exch) 2695 { 2696 if (exch == NULL) 2697 return; 2698 2699 async_sess_t *sess = exch->sess; 2700 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2701 2702 async_exchange_end(exch); 2703 fibril_mutex_unlock(&sess->remote_state_mtx); 2704 } 2705 2431 2706 /** @} 2432 2707 */ -
uspace/lib/c/generic/ddi.c
r867e2555 r925a21e 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 #include <sys/types.h> 36 #include <abi/ddi/arg.h> 35 37 #include <ddi.h> 36 38 #include <libarch/ddi.h> … … 40 42 #include <align.h> 41 43 #include <libarch/config.h> 42 #include <kernel/ddi/ddi_arg.h>43 44 44 45 /** Return unique device number. -
uspace/lib/c/generic/devman.c
r867e2555 r925a21e 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 20 09Jiri Svoboda3 * Copyright (c) 2011 Jiri Svoboda 4 4 * Copyright (c) 2010 Lenka Trochtova 5 5 * All rights reserved. … … 89 89 if (devman_driver_block_sess == NULL) 90 90 devman_driver_block_sess = 91 service_connect_blocking(EXCHANGE_ SERIALIZE,91 service_connect_blocking(EXCHANGE_PARALLEL, 92 92 SERVICE_DEVMAN, DEVMAN_DRIVER, 0); 93 93 } … … 138 138 if (devman_driver_sess == NULL) 139 139 devman_driver_sess = 140 service_connect(EXCHANGE_ SERIALIZE, SERVICE_DEVMAN,140 service_connect(EXCHANGE_PARALLEL, SERVICE_DEVMAN, 141 141 DEVMAN_DRIVER, 0); 142 142 … … 195 195 196 196 exch = devman_exchange_begin(DEVMAN_DRIVER); 197 async_connect_to_me(exch, 0, 0, 0, NULL, NULL);197 async_connect_to_me(exch, 0, 0, 0, conn, NULL); 198 198 devman_exchange_end(exch); 199 199 … … 271 271 } 272 272 273 int devman_add_device_to_c lass(devman_handle_t devman_handle,274 const char *c lass_name)273 int devman_add_device_to_category(devman_handle_t devman_handle, 274 const char *cat_name) 275 275 { 276 276 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER); 277 277 278 278 ipc_call_t answer; 279 aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_C LASS,279 aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_CATEGORY, 280 280 devman_handle, &answer); 281 sysarg_t retval = async_data_write_start(exch, c lass_name,282 str_size(c lass_name));281 sysarg_t retval = async_data_write_start(exch, cat_name, 282 str_size(cat_name)); 283 283 284 284 devman_exchange_end(exch); … … 308 308 } 309 309 310 /** Remove function from device. 311 * 312 * Request devman to remove function owned by this driver task. 313 * @param funh Devman handle of the function 314 * 315 * @return EOK on success or negative error code. 316 */ 317 int devman_remove_function(devman_handle_t funh) 318 { 319 async_exch_t *exch; 320 sysarg_t retval; 321 322 exch = devman_exchange_begin_blocking(DEVMAN_DRIVER); 323 retval = async_req_1_0(exch, DEVMAN_REMOVE_FUNCTION, (sysarg_t) funh); 324 devman_exchange_end(exch); 325 326 return (int) retval; 327 } 328 329 int devman_drv_fun_online(devman_handle_t funh) 330 { 331 async_exch_t *exch = devman_exchange_begin(DEVMAN_DRIVER); 332 if (exch == NULL) 333 return ENOMEM; 334 335 sysarg_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_ONLINE, funh); 336 337 devman_exchange_end(exch); 338 return (int) retval; 339 } 340 341 int devman_drv_fun_offline(devman_handle_t funh) 342 { 343 async_exch_t *exch = devman_exchange_begin(DEVMAN_DRIVER); 344 if (exch == NULL) 345 return ENOMEM; 346 347 sysarg_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_OFFLINE, funh); 348 349 devman_exchange_end(exch); 350 return (int) retval; 351 } 352 310 353 async_sess_t *devman_parent_device_connect(exch_mgmt_t mgmt, 311 354 devman_handle_t handle, unsigned int flags) … … 323 366 } 324 367 325 int devman_ device_get_handle(const char *pathname, devman_handle_t *handle,368 int devman_fun_get_handle(const char *pathname, devman_handle_t *handle, 326 369 unsigned int flags) 327 370 { … … 333 376 exch = devman_exchange_begin(DEVMAN_CLIENT); 334 377 if (exch == NULL) 335 return errno;378 return ENOMEM; 336 379 } 337 380 … … 364 407 } 365 408 366 int devman_device_get_handle_by_class(const char *classname,367 const char *devname, devman_handle_t *handle, unsigned int flags)409 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf, 410 size_t buf_size) 368 411 { 369 412 async_exch_t *exch; 370 371 if (flags & IPC_FLAG_BLOCKING) 372 exch = devman_exchange_begin_blocking(DEVMAN_CLIENT); 373 else { 374 exch = devman_exchange_begin(DEVMAN_CLIENT); 375 if (exch == NULL) 376 return errno; 377 } 413 ipc_call_t dreply; 414 size_t act_size; 415 sysarg_t dretval; 416 417 exch = devman_exchange_begin_blocking(LOC_PORT_CONSUMER); 378 418 379 419 ipc_call_t answer; 380 aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,381 flags, &answer);382 sysarg_t retval = async_data_write_start(exch, classname,383 str_size(classname));384 385 if (retval != EOK) {386 devman_exchange_end(exch);420 aid_t req = async_send_1(exch, method, arg1, &answer); 421 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 422 async_wait_for(dreq, &dretval); 423 424 devman_exchange_end(exch); 425 426 if (dretval != EOK) { 387 427 async_wait_for(req, NULL); 388 return retval; 389 } 390 391 retval = async_data_write_start(exch, devname, 392 str_size(devname)); 393 394 devman_exchange_end(exch); 395 396 if (retval != EOK) { 397 async_wait_for(req, NULL); 398 return retval; 399 } 400 428 return dretval; 429 } 430 431 sysarg_t retval; 401 432 async_wait_for(req, &retval); 402 433 403 if (retval != EOK) { 404 if (handle != NULL) 405 *handle = (devman_handle_t) -1; 406 407 return retval; 408 } 409 410 if (handle != NULL) 411 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 412 413 return retval; 414 } 415 416 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size) 434 if (retval != EOK) 435 return retval; 436 437 act_size = IPC_GET_ARG2(dreply); 438 assert(act_size <= buf_size - 1); 439 buf[act_size] = '\0'; 440 441 return EOK; 442 } 443 444 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 445 { 446 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 447 buf_size); 448 } 449 450 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 451 { 452 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 453 buf_size); 454 } 455 456 int devman_fun_online(devman_handle_t funh) 417 457 { 418 458 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 419 459 if (exch == NULL) 420 return errno; 421 460 return ENOMEM; 461 462 sysarg_t retval = async_req_1_0(exch, DEVMAN_FUN_ONLINE, funh); 463 464 devman_exchange_end(exch); 465 return (int) retval; 466 } 467 468 int devman_fun_offline(devman_handle_t funh) 469 { 470 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 471 if (exch == NULL) 472 return ENOMEM; 473 474 sysarg_t retval = async_req_1_0(exch, DEVMAN_FUN_OFFLINE, funh); 475 476 devman_exchange_end(exch); 477 return (int) retval; 478 } 479 480 static int devman_get_handles_once(sysarg_t method, sysarg_t arg1, 481 devman_handle_t *handle_buf, size_t buf_size, size_t *act_size) 482 { 483 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_CLIENT); 484 422 485 ipc_call_t answer; 423 aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_DEVICE_PATH, 424 handle, &answer); 425 426 ipc_call_t data_request_call; 427 aid_t data_request = async_data_read(exch, path, path_size, 428 &data_request_call); 429 430 devman_exchange_end(exch); 431 432 if (data_request == 0) { 486 aid_t req = async_send_1(exch, method, arg1, &answer); 487 int rc = async_data_read_start(exch, handle_buf, buf_size); 488 489 devman_exchange_end(exch); 490 491 if (rc != EOK) { 433 492 async_wait_for(req, NULL); 434 return ENOMEM; 435 } 436 437 sysarg_t data_request_rc; 438 async_wait_for(data_request, &data_request_rc); 439 440 sysarg_t opening_request_rc; 441 async_wait_for(req, &opening_request_rc); 442 443 if (data_request_rc != EOK) { 444 /* Prefer the return code of the opening request. */ 445 if (opening_request_rc != EOK) 446 return (int) opening_request_rc; 447 else 448 return (int) data_request_rc; 449 } 450 451 if (opening_request_rc != EOK) 452 return (int) opening_request_rc; 453 454 /* To be on the safe-side. */ 455 path[path_size - 1] = 0; 456 size_t transferred_size = IPC_GET_ARG2(data_request_call); 457 if (transferred_size >= path_size) 458 return ELIMIT; 459 460 /* Terminate the string (trailing 0 not send over IPC). */ 461 path[transferred_size] = 0; 493 return rc; 494 } 495 496 sysarg_t retval; 497 async_wait_for(req, &retval); 498 499 if (retval != EOK) { 500 return retval; 501 } 502 503 *act_size = IPC_GET_ARG1(answer); 462 504 return EOK; 463 505 } 464 506 507 /** Get list of handles. 508 * 509 * Returns an allocated array of handles. 510 * 511 * @param method IPC method 512 * @param arg1 IPC argument 1 513 * @param data Place to store pointer to array of handles 514 * @param count Place to store number of handles 515 * @return EOK on success or negative error code 516 */ 517 static int devman_get_handles_internal(sysarg_t method, sysarg_t arg1, 518 devman_handle_t **data, size_t *count) 519 { 520 devman_handle_t *handles; 521 size_t act_size; 522 size_t alloc_size; 523 int rc; 524 525 *data = NULL; 526 act_size = 0; /* silence warning */ 527 528 rc = devman_get_handles_once(method, arg1, NULL, 0, 529 &act_size); 530 if (rc != EOK) 531 return rc; 532 533 alloc_size = act_size; 534 handles = malloc(alloc_size); 535 if (handles == NULL) 536 return ENOMEM; 537 538 while (true) { 539 rc = devman_get_handles_once(method, arg1, handles, alloc_size, 540 &act_size); 541 if (rc != EOK) 542 return rc; 543 544 if (act_size <= alloc_size) 545 break; 546 547 alloc_size *= 2; 548 free(handles); 549 550 handles = malloc(alloc_size); 551 if (handles == NULL) 552 return ENOMEM; 553 } 554 555 *count = act_size / sizeof(devman_handle_t); 556 *data = handles; 557 return EOK; 558 } 559 560 int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh) 561 { 562 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 563 if (exch == NULL) 564 return ENOMEM; 565 566 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_GET_CHILD, 567 funh, devh); 568 569 devman_exchange_end(exch); 570 return (int) retval; 571 } 572 573 int devman_dev_get_functions(devman_handle_t devh, devman_handle_t **funcs, 574 size_t *count) 575 { 576 return devman_get_handles_internal(DEVMAN_DEV_GET_FUNCTIONS, 577 devh, funcs, count); 578 } 579 580 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 581 { 582 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 583 if (exch == NULL) 584 return ENOMEM; 585 586 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE, 587 sid, handle); 588 589 devman_exchange_end(exch); 590 return (int) retval; 591 } 592 465 593 /** @} 466 594 */ -
uspace/lib/c/generic/event.c
r867e2555 r925a21e 39 39 #include <libc.h> 40 40 #include <event.h> 41 #include <kernel/ipc/event_types.h>42 41 43 42 /** Subscribe event notifications. … … 50 49 */ 51 50 int event_subscribe(event_type_t evno, sysarg_t imethod) 51 { 52 return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno, 53 (sysarg_t) imethod); 54 } 55 56 int event_task_subscribe(event_task_type_t evno, sysarg_t imethod) 52 57 { 53 58 return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno, … … 67 72 } 68 73 74 int event_task_unmask(event_task_type_t evno) 75 { 76 return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno); 77 } 78 69 79 /** @} 70 80 */ -
uspace/lib/c/generic/fibril.c
r867e2555 r925a21e 41 41 #include <unistd.h> 42 42 #include <stdio.h> 43 #include < arch/barrier.h>43 #include <libarch/barrier.h> 44 44 #include <libarch/faddr.h> 45 45 #include <futex.h> -
uspace/lib/c/generic/io/console.c
r867e2555 r925a21e 87 87 { 88 88 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 89 async_ msg_0(exch, CONSOLE_CLEAR);89 async_req_0_0(exch, CONSOLE_CLEAR); 90 90 async_exchange_end(exch); 91 91 } … … 103 103 { 104 104 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 105 async_ msg_1(exch, CONSOLE_SET_STYLE, style);106 async_exchange_end(exch); 107 } 108 109 void console_set_color(console_ctrl_t *ctrl, uint8_t fg_color, uint8_t bg_color,105 async_req_1_0(exch, CONSOLE_SET_STYLE, style); 106 async_exchange_end(exch); 107 } 108 109 void console_set_color(console_ctrl_t *ctrl, uint8_t bgcolor, uint8_t fgcolor, 110 110 uint8_t flags) 111 111 { 112 112 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 113 async_ msg_3(exch, CONSOLE_SET_COLOR, fg_color, bg_color, flags);114 async_exchange_end(exch); 115 } 116 117 void console_set_rgb_color(console_ctrl_t *ctrl, uint32_t fg_color,118 uint32_t bg_color)119 { 120 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 121 async_ msg_2(exch, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);113 async_req_3_0(exch, CONSOLE_SET_COLOR, bgcolor, fgcolor, flags); 114 async_exchange_end(exch); 115 } 116 117 void console_set_rgb_color(console_ctrl_t *ctrl, uint32_t bgcolor, 118 uint32_t fgcolor) 119 { 120 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 121 async_req_2_0(exch, CONSOLE_SET_RGB_COLOR, bgcolor, fgcolor); 122 122 async_exchange_end(exch); 123 123 } … … 126 126 { 127 127 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 128 async_ msg_1(exch, CONSOLE_CURSOR_VISIBILITY, (show != false));128 async_req_1_0(exch, CONSOLE_CURSOR_VISIBILITY, (show != false)); 129 129 async_exchange_end(exch); 130 130 } … … 151 151 { 152 152 async_exch_t *exch = async_exchange_begin(ctrl->output_sess); 153 async_ msg_2(exch, CONSOLE_GOTO, col, row);153 async_req_2_0(exch, CONSOLE_GOTO, col, row); 154 154 async_exchange_end(exch); 155 155 } -
uspace/lib/c/generic/io/io.c
r867e2555 r925a21e 45 45 #include <vfs/vfs.h> 46 46 #include <vfs/vfs_sess.h> 47 #include <ipc/ devmap.h>47 #include <ipc/loc.h> 48 48 #include <adt/list.h> 49 49 #include "../private/io.h" … … 101 101 static LIST_INITIALIZE(files); 102 102 103 void __stdio_init(int filc , fdi_node_t *filv[])103 void __stdio_init(int filc) 104 104 { 105 105 if (filc > 0) { 106 stdin = f open_node(filv[0], "r");106 stdin = fdopen(0, "r"); 107 107 } else { 108 108 stdin = &stdin_null; … … 111 111 112 112 if (filc > 1) { 113 stdout = f open_node(filv[1], "w");113 stdout = fdopen(1, "w"); 114 114 } else { 115 115 stdout = &stdout_klog; … … 118 118 119 119 if (filc > 2) { 120 stderr = f open_node(filv[2], "w");120 stderr = fdopen(2, "w"); 121 121 } else { 122 122 stderr = &stderr_klog; … … 285 285 } 286 286 287 FILE *fopen_node(fdi_node_t *node, const char *mode)288 {289 int flags;290 if (!parse_mode(mode, &flags))291 return NULL;292 293 /* Open file. */294 FILE *stream = malloc(sizeof(FILE));295 if (stream == NULL) {296 errno = ENOMEM;297 return NULL;298 }299 300 stream->fd = open_node(node, flags);301 if (stream->fd < 0) {302 /* errno was set by open_node() */303 free(stream);304 return NULL;305 }306 307 stream->error = false;308 stream->eof = false;309 stream->klog = false;310 stream->sess = NULL;311 stream->need_sync = false;312 _setvbuf(stream);313 314 list_append(&stream->link, &files);315 316 return stream;317 }318 319 287 int fclose(FILE *stream) 320 288 { … … 450 418 451 419 bytes_used = stream->buf_head - stream->buf_tail; 452 if (bytes_used == 0)453 return;454 420 455 421 /* If buffer has prefetched read data, we need to seek back. */ 456 if ( stream->buf_state == _bs_read)422 if (bytes_used > 0 && stream->buf_state == _bs_read) 457 423 lseek(stream->fd, - (ssize_t) bytes_used, SEEK_CUR); 458 424 459 425 /* If buffer has unwritten data, we need to write them out. */ 460 if ( stream->buf_state == _bs_write)426 if (bytes_used > 0 && stream->buf_state == _bs_write) 461 427 (void) _fwrite(stream->buf_tail, 1, bytes_used, stream); 462 428 … … 780 746 } 781 747 782 int fnode(FILE *stream, fdi_node_t *node) 783 { 784 if (stream->fd >= 0) 785 return fd_node(stream->fd, node); 748 int fhandle(FILE *stream, int *handle) 749 { 750 if (stream->fd >= 0) { 751 *handle = stream->fd; 752 return EOK; 753 } 786 754 787 755 return ENOENT; -
uspace/lib/c/generic/io/printf_core.c
r867e2555 r925a21e 74 74 #define PRINT_NUMBER_BUFFER_SIZE (64 + 5) 75 75 76 /** Get signed or unsigned integer argument */ 77 #define PRINTF_GET_INT_ARGUMENT(type, ap, flags) \ 78 ({ \ 79 unsigned type res; \ 80 \ 81 if ((flags) & __PRINTF_FLAG_SIGNED) { \ 82 signed type arg = va_arg((ap), signed type); \ 83 \ 84 if (arg < 0) { \ 85 res = -arg; \ 86 (flags) |= __PRINTF_FLAG_NEGATIVE; \ 87 } else \ 88 res = arg; \ 89 } else \ 90 res = va_arg((ap), unsigned type); \ 91 \ 92 res; \ 93 }) 94 76 95 /** Enumeration of possible arguments types. 77 96 */ … … 206 225 } 207 226 208 return (int) (counter + 1);227 return (int) (counter); 209 228 } 210 229 … … 244 263 } 245 264 246 return (int) (counter + 1);265 return (int) (counter); 247 266 } 248 267 … … 831 850 size_t size; 832 851 uint64_t number; 852 833 853 switch (qualifier) { 834 854 case PrintfQualifierByte: 835 855 size = sizeof(unsigned char); 836 number = (uint64_t) va_arg(ap, unsigned int);856 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 837 857 break; 838 858 case PrintfQualifierShort: 839 859 size = sizeof(unsigned short); 840 number = (uint64_t) va_arg(ap, unsigned int);860 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 841 861 break; 842 862 case PrintfQualifierInt: 843 863 size = sizeof(unsigned int); 844 number = (uint64_t) va_arg(ap, unsigned int);864 number = PRINTF_GET_INT_ARGUMENT(int, ap, flags); 845 865 break; 846 866 case PrintfQualifierLong: 847 867 size = sizeof(unsigned long); 848 number = (uint64_t) va_arg(ap, unsigned long);868 number = PRINTF_GET_INT_ARGUMENT(long, ap, flags); 849 869 break; 850 870 case PrintfQualifierLongLong: 851 871 size = sizeof(unsigned long long); 852 number = (uint64_t) va_arg(ap, unsigned long long);872 number = PRINTF_GET_INT_ARGUMENT(long long, ap, flags); 853 873 break; 854 874 case PrintfQualifierPointer: … … 865 885 counter = -counter; 866 886 goto out; 867 }868 869 if (flags & __PRINTF_FLAG_SIGNED) {870 if (number & (0x1 << (size * 8 - 1))) {871 flags |= __PRINTF_FLAG_NEGATIVE;872 873 if (size == sizeof(uint64_t)) {874 number = -((int64_t) number);875 } else {876 number = ~number;877 number &=878 ~(0xFFFFFFFFFFFFFFFFll <<879 (size * 8));880 number++;881 }882 }883 887 } 884 888 -
uspace/lib/c/generic/ipc.c
r867e2555 r925a21e 47 47 #include <futex.h> 48 48 #include <fibril.h> 49 #include <macros.h> 49 50 50 51 /** … … 611 612 /** Request callback connection. 612 613 * 613 * The @a task hashand @a phonehash identifiers returned614 * The @a task_id and @a phonehash identifiers returned 614 615 * by the kernel can be used for connection tracking. 615 616 * … … 618 619 * @param arg2 User defined argument. 619 620 * @param arg3 User defined argument. 620 * @param task hash Opaque identifier of the client task.621 * @param task_id Identifier of the client task. 621 622 * @param phonehash Opaque identifier of the phone that will 622 623 * be used for incoming calls. … … 626 627 */ 627 628 int ipc_connect_to_me(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 628 sysarg_t *taskhash, sysarg_t *phonehash) 629 { 630 return ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, 631 arg3, NULL, NULL, NULL, taskhash, phonehash); 629 task_id_t *task_id, sysarg_t *phonehash) 630 { 631 ipc_call_t data; 632 int rc = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, 633 IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, (sysarg_t) &data); 634 if (rc == EOK) { 635 *task_id = data.in_task_id; 636 *phonehash = IPC_GET_ARG5(data); 637 } 638 return rc; 632 639 } 633 640 -
uspace/lib/c/generic/libc.c
r867e2555 r925a21e 91 91 argc = 0; 92 92 argv = NULL; 93 __stdio_init(0 , NULL);93 __stdio_init(0); 94 94 } else { 95 95 argc = __pcb->argc; 96 96 argv = __pcb->argv; 97 __stdio_init(__pcb->filc , __pcb->filv);97 __stdio_init(__pcb->filc); 98 98 (void) chdir(__pcb->cwd); 99 99 } -
uspace/lib/c/generic/loader.c
r867e2555 r925a21e 256 256 * 257 257 */ 258 int loader_set_files(loader_t *ldr, fdi_node_t *const files[]) 259 { 260 /* 261 * Serialize the arguments into a single array. First 262 * compute size of the buffer needed. 263 */ 264 fdi_node_t *const *ap = files; 265 size_t count = 0; 266 while (*ap != NULL) { 267 count++; 268 ap++; 269 } 270 271 fdi_node_t *files_buf; 272 files_buf = (fdi_node_t *) malloc(count * sizeof(fdi_node_t)); 273 if (files_buf == NULL) 274 return ENOMEM; 275 276 /* Fill the buffer */ 277 size_t i; 278 for (i = 0; i < count; i++) 279 files_buf[i] = *files[i]; 280 258 int loader_set_files(loader_t *ldr, int * const files[]) 259 { 281 260 /* Send serialized files to the loader */ 282 261 async_exch_t *exch = async_exchange_begin(ldr->sess); 283 284 ipc_call_t answer; 285 aid_t req = async_send_0(exch, LOADER_SET_FILES, &answer); 286 sysarg_t rc = async_data_write_start(exch, (void *) files_buf, 287 count * sizeof(fdi_node_t)); 288 289 async_exchange_end(exch); 290 free(files_buf); 291 262 async_exch_t *vfs_exch = vfs_exchange_begin(); 263 264 int i; 265 for (i = 0; files[i]; i++); 266 267 ipc_call_t answer; 268 aid_t req = async_send_1(exch, LOADER_SET_FILES, i, &answer); 269 270 sysarg_t rc = EOK; 271 272 for (i = 0; files[i]; i++) { 273 rc = async_state_change_start(exch, VFS_PASS_HANDLE, *files[i], 274 0, vfs_exch); 275 if (rc != EOK) 276 break; 277 } 278 279 vfs_exchange_end(vfs_exch); 280 async_exchange_end(exch); 281 292 282 if (rc != EOK) { 293 283 async_wait_for(req, NULL); -
uspace/lib/c/generic/malloc.c
r867e2555 r925a21e 873 873 void free(const void *addr) 874 874 { 875 if (addr == NULL) 876 return; 877 875 878 futex_down(&malloc_futex); 876 879 -
uspace/lib/c/generic/ns.c
r867e2555 r925a21e 52 52 { 53 53 async_exch_t *exch = async_exchange_begin(session_ns); 54 if (!exch) 55 return NULL; 54 56 async_sess_t *sess = 55 57 async_connect_me_to(mgmt, exch, service, arg2, arg3); 56 58 async_exchange_end(exch); 59 60 if (!sess) 61 return NULL; 62 63 /* 64 * FIXME Ugly hack to work around limitation of implementing 65 * parallel exchanges using multiple connections. Shift out 66 * first argument for non-initial connections. 67 */ 68 async_sess_args_set(sess, arg2, arg3, 0); 57 69 58 70 return sess; … … 66 78 async_connect_me_to_blocking(mgmt, exch, service, arg2, arg3); 67 79 async_exchange_end(exch); 80 81 /* 82 * FIXME Ugly hack to work around limitation of implementing 83 * parallel exchanges using multiple connections. Shift out 84 * first argument for non-initial connections. 85 */ 86 async_sess_args_set(sess, arg2, arg3, 0); 68 87 69 88 return sess; -
uspace/lib/c/generic/private/async.h
r867e2555 r925a21e 36 36 #define LIBC_PRIVATE_ASYNC_H_ 37 37 38 #include <async.h> 38 39 #include <adt/list.h> 39 40 #include <fibril.h> 41 #include <fibril_synch.h> 40 42 #include <sys/time.h> 41 43 #include <bool.h> … … 79 81 } awaiter_t; 80 82 81 /** Message data */82 typedef struct {83 awaiter_t wdata;84 85 /** If reply was received. */86 bool done;87 88 /** Pointer to where the answer data is stored. */89 ipc_call_t *dataptr;90 91 sysarg_t retval;92 } amsg_t;93 94 83 extern void __async_init(void); 95 84 extern void async_insert_timeout(awaiter_t *); -
uspace/lib/c/generic/private/io.h
r867e2555 r925a21e 36 36 #define LIBC_PRIVATE_IO_H_ 37 37 38 #include <vfs/vfs.h> 39 40 extern void __stdio_init(int filc, fdi_node_t *filv[]); 38 extern void __stdio_init(int); 41 39 extern void __stdio_done(void); 42 40 -
uspace/lib/c/generic/private/thread.h
r867e2555 r925a21e 36 36 #define LIBC_PRIVATE_THREAD_H_ 37 37 38 #include < kernel/proc/uarg.h>38 #include <abi/proc/uarg.h> 39 39 40 40 extern void __thread_entry(void); -
uspace/lib/c/generic/str.c
r867e2555 r925a21e 2 2 * Copyright (c) 2005 Martin Decky 3 3 * Copyright (c) 2008 Jiri Svoboda 4 * Copyright (c) 2011 Martin Sucha 5 * Copyright (c) 2011 Oleg Romanenko 4 6 * All rights reserved. 5 7 * … … 549 551 * 550 552 * Common legacy text encoding in hardware is 7-bit ASCII fitted into 551 * a fixed-wi th byte buffer (bit 7 always zero), right-padded with spaces553 * a fixed-width byte buffer (bit 7 always zero), right-padded with spaces 552 554 * (ASCII 0x20). Convert space-padded ascii to string representation. 553 555 * … … 639 641 } 640 642 643 /** Convert UTF16 string to string. 644 * 645 * Convert utf16 string @a src to string. The output is written to the buffer 646 * specified by @a dest and @a size. @a size must be non-zero and the string 647 * written will always be well-formed. Surrogate pairs also supported. 648 * 649 * @param dest Destination buffer. 650 * @param size Size of the destination buffer. 651 * @param src Source utf16 string. 652 * 653 * @return EOK, if success, negative otherwise. 654 */ 655 int utf16_to_str(char *dest, size_t size, const uint16_t *src) 656 { 657 size_t idx = 0, dest_off = 0; 658 wchar_t ch; 659 int rc = EOK; 660 661 /* There must be space for a null terminator in the buffer. */ 662 assert(size > 0); 663 664 while (src[idx]) { 665 if ((src[idx] & 0xfc00) == 0xd800) { 666 if (src[idx + 1] && (src[idx + 1] & 0xfc00) == 0xdc00) { 667 ch = 0x10000; 668 ch += (src[idx] & 0x03FF) << 10; 669 ch += (src[idx + 1] & 0x03FF); 670 idx += 2; 671 } 672 else 673 break; 674 } else { 675 ch = src[idx]; 676 idx++; 677 } 678 rc = chr_encode(ch, dest, &dest_off, size - 1); 679 if (rc != EOK) 680 break; 681 } 682 dest[dest_off] = '\0'; 683 return rc; 684 } 685 686 int str_to_utf16(uint16_t *dest, size_t size, const char *src) 687 { 688 int rc = EOK; 689 size_t offset = 0; 690 size_t idx = 0; 691 wchar_t c; 692 693 assert(size > 0); 694 695 while ((c = str_decode(src, &offset, STR_NO_LIMIT)) != 0) { 696 if (c > 0x10000) { 697 if (idx + 2 >= size - 1) { 698 rc = EOVERFLOW; 699 break; 700 } 701 c = (c - 0x10000); 702 dest[idx] = 0xD800 | (c >> 10); 703 dest[idx + 1] = 0xDC00 | (c & 0x3FF); 704 idx++; 705 } else { 706 dest[idx] = c; 707 } 708 709 idx++; 710 if (idx >= size - 1) { 711 rc = EOVERFLOW; 712 break; 713 } 714 } 715 716 dest[idx] = '\0'; 717 return rc; 718 } 719 720 641 721 /** Convert wide string to new string. 642 722 * … … 718 798 719 799 dest[dlen - 1] = '\0'; 800 } 801 802 /** Convert string to wide string. 803 * 804 * Convert string @a src to wide string. A new wide NULL-terminated 805 * string will be allocated on the heap. 806 * 807 * @param src Source string. 808 */ 809 wchar_t *str_to_awstr(const char *str) 810 { 811 size_t len = str_length(str); 812 813 wchar_t *wstr = calloc(len+1, sizeof(wchar_t)); 814 if (wstr == NULL) 815 return NULL; 816 817 str_to_wstr(wstr, len + 1, str); 818 return wstr; 720 819 } 721 820 … … 1016 1115 return dest; 1017 1116 } 1018 1019 1117 1020 1118 /** Convert initial part of string to unsigned long according to given base. … … 1193 1291 } 1194 1292 1293 /** Convert string to uint8_t. 1294 * 1295 * @param nptr Pointer to string. 1296 * @param endptr If not NULL, pointer to the first invalid character 1297 * is stored here. 1298 * @param base Zero or number between 2 and 36 inclusive. 1299 * @param strict Do not allow any trailing characters. 1300 * @param result Result of the conversion. 1301 * 1302 * @return EOK if conversion was successful. 1303 * 1304 */ 1305 int str_uint8_t(const char *nptr, char **endptr, unsigned int base, 1306 bool strict, uint8_t *result) 1307 { 1308 assert(result != NULL); 1309 1310 bool neg; 1311 char *lendptr; 1312 uint64_t res; 1313 int ret = str_uint(nptr, &lendptr, base, &neg, &res); 1314 1315 if (endptr != NULL) 1316 *endptr = (char *) lendptr; 1317 1318 if (ret != EOK) 1319 return ret; 1320 1321 /* Do not allow negative values */ 1322 if (neg) 1323 return EINVAL; 1324 1325 /* Check whether we are at the end of 1326 the string in strict mode */ 1327 if ((strict) && (*lendptr != 0)) 1328 return EINVAL; 1329 1330 /* Check for overflow */ 1331 uint8_t _res = (uint8_t) res; 1332 if (_res != res) 1333 return EOVERFLOW; 1334 1335 *result = _res; 1336 1337 return EOK; 1338 } 1339 1340 /** Convert string to uint16_t. 1341 * 1342 * @param nptr Pointer to string. 1343 * @param endptr If not NULL, pointer to the first invalid character 1344 * is stored here. 1345 * @param base Zero or number between 2 and 36 inclusive. 1346 * @param strict Do not allow any trailing characters. 1347 * @param result Result of the conversion. 1348 * 1349 * @return EOK if conversion was successful. 1350 * 1351 */ 1352 int str_uint16_t(const char *nptr, char **endptr, unsigned int base, 1353 bool strict, uint16_t *result) 1354 { 1355 assert(result != NULL); 1356 1357 bool neg; 1358 char *lendptr; 1359 uint64_t res; 1360 int ret = str_uint(nptr, &lendptr, base, &neg, &res); 1361 1362 if (endptr != NULL) 1363 *endptr = (char *) lendptr; 1364 1365 if (ret != EOK) 1366 return ret; 1367 1368 /* Do not allow negative values */ 1369 if (neg) 1370 return EINVAL; 1371 1372 /* Check whether we are at the end of 1373 the string in strict mode */ 1374 if ((strict) && (*lendptr != 0)) 1375 return EINVAL; 1376 1377 /* Check for overflow */ 1378 uint16_t _res = (uint16_t) res; 1379 if (_res != res) 1380 return EOVERFLOW; 1381 1382 *result = _res; 1383 1384 return EOK; 1385 } 1386 1387 /** Convert string to uint32_t. 1388 * 1389 * @param nptr Pointer to string. 1390 * @param endptr If not NULL, pointer to the first invalid character 1391 * is stored here. 1392 * @param base Zero or number between 2 and 36 inclusive. 1393 * @param strict Do not allow any trailing characters. 1394 * @param result Result of the conversion. 1395 * 1396 * @return EOK if conversion was successful. 1397 * 1398 */ 1399 int str_uint32_t(const char *nptr, char **endptr, unsigned int base, 1400 bool strict, uint32_t *result) 1401 { 1402 assert(result != NULL); 1403 1404 bool neg; 1405 char *lendptr; 1406 uint64_t res; 1407 int ret = str_uint(nptr, &lendptr, base, &neg, &res); 1408 1409 if (endptr != NULL) 1410 *endptr = (char *) lendptr; 1411 1412 if (ret != EOK) 1413 return ret; 1414 1415 /* Do not allow negative values */ 1416 if (neg) 1417 return EINVAL; 1418 1419 /* Check whether we are at the end of 1420 the string in strict mode */ 1421 if ((strict) && (*lendptr != 0)) 1422 return EINVAL; 1423 1424 /* Check for overflow */ 1425 uint32_t _res = (uint32_t) res; 1426 if (_res != res) 1427 return EOVERFLOW; 1428 1429 *result = _res; 1430 1431 return EOK; 1432 } 1433 1195 1434 /** Convert string to uint64_t. 1196 1435 * -
uspace/lib/c/generic/sysinfo.c
r867e2555 r925a21e 47 47 * 48 48 */ 49 sysinfo_item_ tag_t sysinfo_get_tag(const char *path)49 sysinfo_item_val_type_t sysinfo_get_val_type(const char *path) 50 50 { 51 return (sysinfo_item_ tag_t) __SYSCALL2(SYS_SYSINFO_GET_TAG,51 return (sysinfo_item_val_type_t) __SYSCALL2(SYS_SYSINFO_GET_VAL_TYPE, 52 52 (sysarg_t) path, (sysarg_t) str_size(path)); 53 53 } -
uspace/lib/c/generic/task.c
r867e2555 r925a21e 46 46 #include <libc.h> 47 47 #include "private/ns.h" 48 #include <vfs/vfs.h> 48 49 49 50 task_id_t task_get_id(void) … … 102 103 { 103 104 /* Send default files */ 104 fdi_node_t *files[4];105 fdi_node_t stdin_node;106 fdi_node_t stdout_node;107 fdi_node_t stderr_node;108 109 if ((stdin != NULL) && (f node(stdin, &stdin_node) == EOK))110 files[0] = & stdin_node;105 int *files[4]; 106 int fd_stdin; 107 int fd_stdout; 108 int fd_stderr; 109 110 if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK)) 111 files[0] = &fd_stdin; 111 112 else 112 113 files[0] = NULL; 113 114 114 if ((stdout != NULL) && (f node(stdout, &stdout_node) == EOK))115 files[1] = & stdout_node;115 if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK)) 116 files[1] = &fd_stdout; 116 117 else 117 118 files[1] = NULL; 118 119 119 if ((stderr != NULL) && (f node(stderr, &stderr_node) == EOK))120 files[2] = & stderr_node;120 if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK)) 121 files[2] = &fd_stderr; 121 122 else 122 123 files[2] = NULL; … … 142 143 */ 143 144 int task_spawnvf(task_id_t *id, const char *path, const char *const args[], 144 fdi_node_t *const files[])145 int *const files[]) 145 146 { 146 147 /* Connect to a program loader. */ -
uspace/lib/c/generic/thread.c
r867e2555 r925a21e 37 37 #include <stdlib.h> 38 38 #include <libarch/faddr.h> 39 #include < kernel/proc/uarg.h>39 #include <abi/proc/uarg.h> 40 40 #include <fibril.h> 41 41 #include <str.h> -
uspace/lib/c/generic/time.c
r867e2555 r925a21e 36 36 #include <time.h> 37 37 #include <bool.h> 38 #include < arch/barrier.h>38 #include <libarch/barrier.h> 39 39 #include <macros.h> 40 40 #include <errno.h> -
uspace/lib/c/generic/udebug.c
r867e2555 r925a21e 35 35 #include <udebug.h> 36 36 #include <sys/types.h> 37 #include < kernel/ipc/ipc_methods.h>37 #include <abi/ipc/methods.h> 38 38 #include <async.h> 39 39 -
uspace/lib/c/generic/vfs/vfs.c
r867e2555 r925a21e 51 51 #include <assert.h> 52 52 #include <str.h> 53 #include < devmap.h>53 #include <loc.h> 54 54 #include <ipc/vfs.h> 55 #include <ipc/ devmap.h>55 #include <ipc/loc.h> 56 56 57 57 static FIBRIL_MUTEX_INITIALIZE(vfs_mutex); … … 69 69 * 70 70 */ 71 staticasync_exch_t *vfs_exchange_begin(void)71 async_exch_t *vfs_exchange_begin(void) 72 72 { 73 73 fibril_mutex_lock(&vfs_mutex); … … 87 87 * 88 88 */ 89 staticvoid vfs_exchange_end(async_exch_t *exch)89 void vfs_exchange_end(async_exch_t *exch) 90 90 { 91 91 async_exchange_end(exch); … … 142 142 } 143 143 144 int mount(const char *fs_name, const char *mp, const char *fq dn,145 const char *opts, unsigned int flags )144 int mount(const char *fs_name, const char *mp, const char *fqsn, 145 const char *opts, unsigned int flags, unsigned int instance) 146 146 { 147 147 int null_id = -1; 148 char null[ DEVMAP_NAME_MAXLEN];149 150 if (str_cmp(fq dn, "") == 0) {148 char null[LOC_NAME_MAXLEN]; 149 150 if (str_cmp(fqsn, "") == 0) { 151 151 /* No device specified, create a fresh 152 152 null/%d device instead */ 153 null_id = devmap_null_create();153 null_id = loc_null_create(); 154 154 155 155 if (null_id == -1) 156 156 return ENOMEM; 157 157 158 snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);159 fq dn = null;160 } 161 162 devmap_handle_t devmap_handle;163 int res = devmap_device_get_handle(fqdn, &devmap_handle, flags);158 snprintf(null, LOC_NAME_MAXLEN, "null/%d", null_id); 159 fqsn = null; 160 } 161 162 service_id_t service_id; 163 int res = loc_service_get_id(fqsn, &service_id, flags); 164 164 if (res != EOK) { 165 165 if (null_id != -1) 166 devmap_null_destroy(null_id);166 loc_null_destroy(null_id); 167 167 168 168 return res; … … 173 173 if (!mpa) { 174 174 if (null_id != -1) 175 devmap_null_destroy(null_id);175 loc_null_destroy(null_id); 176 176 177 177 return ENOMEM; … … 181 181 182 182 sysarg_t rc_orig; 183 aid_t req = async_send_2(exch, VFS_IN_MOUNT, devmap_handle, flags, NULL); 183 aid_t req = async_send_3(exch, VFS_IN_MOUNT, service_id, flags, 184 instance, NULL); 184 185 sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size); 185 186 if (rc != EOK) { … … 189 190 190 191 if (null_id != -1) 191 devmap_null_destroy(null_id);192 loc_null_destroy(null_id); 192 193 193 194 if (rc_orig == EOK) … … 204 205 205 206 if (null_id != -1) 206 devmap_null_destroy(null_id);207 loc_null_destroy(null_id); 207 208 208 209 if (rc_orig == EOK) … … 219 220 220 221 if (null_id != -1) 221 devmap_null_destroy(null_id);222 loc_null_destroy(null_id); 222 223 223 224 if (rc_orig == EOK) … … 235 236 236 237 if (null_id != -1) 237 devmap_null_destroy(null_id);238 loc_null_destroy(null_id); 238 239 239 240 if (rc_orig == EOK) … … 248 249 249 250 if ((rc != EOK) && (null_id != -1)) 250 devmap_null_destroy(null_id);251 loc_null_destroy(null_id); 251 252 252 253 return (int) rc; … … 327 328 328 329 return ret; 329 }330 331 int open_node(fdi_node_t *node, int oflag)332 {333 async_exch_t *exch = vfs_exchange_begin();334 335 ipc_call_t answer;336 aid_t req = async_send_4(exch, VFS_IN_OPEN_NODE, node->fs_handle,337 node->devmap_handle, node->index, oflag, &answer);338 339 vfs_exchange_end(exch);340 341 sysarg_t rc;342 async_wait_for(req, &rc);343 344 if (rc != EOK)345 return (int) rc;346 347 return (int) IPC_GET_ARG1(answer);348 330 } 349 331 … … 673 655 async_exch_t *exch = vfs_exchange_begin(); 674 656 675 req = async_send_ 0(exch, VFS_IN_UNLINK, NULL);657 req = async_send_1(exch, VFS_IN_UNLINK, lflag, NULL); 676 658 rc = async_data_write_start(exch, pa, pa_size); 677 659 if (rc != EOK) { … … 811 793 } 812 794 813 if (!stat. device) {795 if (!stat.service) { 814 796 errno = ENOENT; 815 797 return NULL; 816 798 } 817 799 818 return devmap_device_connect(mgmt, stat.device, 0); 819 } 820 821 int fd_node(int fildes, fdi_node_t *node) 822 { 823 struct stat stat; 824 int rc = fstat(fildes, &stat); 825 826 if (rc == EOK) { 827 node->fs_handle = stat.fs_handle; 828 node->devmap_handle = stat.devmap_handle; 829 node->index = stat.index; 830 } 831 832 return rc; 800 return loc_service_connect(mgmt, stat.service, 0); 833 801 } 834 802 … … 848 816 } 849 817 818 int fd_wait(void) 819 { 820 async_exch_t *exch = vfs_exchange_begin(); 821 822 sysarg_t ret; 823 sysarg_t rc = async_req_0_1(exch, VFS_IN_WAIT_HANDLE, &ret); 824 825 vfs_exchange_end(exch); 826 827 if (rc == EOK) 828 return (int) ret; 829 830 return (int) rc; 831 } 832 850 833 /** @} 851 834 */ -
uspace/lib/c/include/adt/list.h
r867e2555 r925a21e 72 72 73 73 #define assert_link_not_used(link) \ 74 assert(( link)->prev == NULL && (link)->next == NULL)74 assert(((link)->prev == NULL) && ((link)->next == NULL)) 75 75 76 76 /** Initialize doubly-linked circular list link … … 158 158 static inline void list_remove(link_t *link) 159 159 { 160 link->next->prev = link->prev; 161 link->prev->next = link->next; 160 if ((link->prev != NULL) && (link->next != NULL)) { 161 link->next->prev = link->prev; 162 link->prev->next = link->next; 163 } 164 162 165 link_initialize(link); 163 166 } … … 170 173 * 171 174 */ 172 static inline int list_empty( list_t *list)175 static inline int list_empty(const list_t *list) 173 176 { 174 177 return (list->head.next == &list->head); … … 183 186 * 184 187 */ 185 static inline link_t *list_first( list_t *list)188 static inline link_t *list_first(const list_t *list) 186 189 { 187 190 return ((list->head.next == &list->head) ? NULL : list->head.next); -
uspace/lib/c/include/as.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include <abi/mm/as.h> 39 40 #include <task.h> 40 #include <kernel/mm/as.h>41 41 #include <libarch/config.h> 42 42 … … 60 60 extern void *set_maxheapsize(size_t); 61 61 extern void *as_get_mappable_page(size_t); 62 extern int as_get_physical_mapping( void *, uintptr_t *);62 extern int as_get_physical_mapping(const void *, uintptr_t *); 63 63 64 64 #endif -
uspace/lib/c/include/async.h
r867e2555 r925a21e 42 42 #include <ipc/common.h> 43 43 #include <fibril.h> 44 #include <fibril_synch.h>45 44 #include <sys/time.h> 46 45 #include <atomic.h> … … 96 95 } exch_mgmt_t; 97 96 98 /** Session data */ 99 typedef struct { 100 /** List of inactive exchanges */ 101 list_t exch_list; 102 103 /** Exchange management style */ 104 exch_mgmt_t mgmt; 105 106 /** Session identification */ 107 int phone; 108 109 /** First clone connection argument */ 110 sysarg_t arg1; 111 112 /** Second clone connection argument */ 113 sysarg_t arg2; 114 115 /** Third clone connection argument */ 116 sysarg_t arg3; 117 118 /** Exchange mutex */ 119 fibril_mutex_t mutex; 120 121 /** Number of opened exchanges */ 122 atomic_t refcnt; 123 } async_sess_t; 124 125 /** Exchange data */ 126 typedef struct { 127 /** Link into list of inactive exchanges */ 128 link_t sess_link; 129 130 /** Link into global list of inactive exchanges */ 131 link_t global_link; 132 133 /** Session pointer */ 134 async_sess_t *sess; 135 136 /** Exchange identification */ 137 int phone; 138 } async_exch_t; 97 /** Forward declarations */ 98 struct async_exch; 99 struct async_sess; 100 101 typedef struct async_sess async_sess_t; 102 typedef struct async_exch async_exch_t; 139 103 140 104 extern atomic_t threads_in_ipc_wait; … … 176 140 extern int async_wait_timeout(aid_t, sysarg_t *, suseconds_t); 177 141 178 extern fid_t async_new_connection( sysarg_t, sysarg_t, ipc_callid_t,142 extern fid_t async_new_connection(task_id_t, sysarg_t, ipc_callid_t, 179 143 ipc_call_t *, async_client_conn_t, void *); 180 144 … … 186 150 extern void async_set_client_data_destructor(async_client_data_dtor_t); 187 151 extern void *async_get_client_data(void); 152 extern void *async_get_client_data_by_id(task_id_t); 153 extern void async_put_client_data_by_id(task_id_t); 188 154 189 155 extern void async_set_client_connection(async_client_conn_t); … … 371 337 372 338 /* 339 * FIXME These functions just work around problems with parallel exchange 340 * management. Proper solution needs to be implemented. 341 */ 342 void async_sess_args_set(async_sess_t *sess, sysarg_t, sysarg_t, sysarg_t); 343 344 /* 373 345 * User-friendly wrappers for async_share_in_start(). 374 346 */ … … 477 449 extern async_sess_t *async_callback_receive_start(exch_mgmt_t, ipc_call_t *); 478 450 451 extern int async_state_change_start(async_exch_t *, sysarg_t, sysarg_t, 452 sysarg_t, async_exch_t *); 453 extern bool async_state_change_receive(ipc_callid_t *, sysarg_t *, sysarg_t *, 454 sysarg_t *); 455 extern int async_state_change_finalize(ipc_callid_t, async_exch_t *); 456 457 extern void *async_remote_state_acquire(async_sess_t *); 458 extern void async_remote_state_update(async_sess_t *, void *); 459 extern void async_remote_state_release(async_sess_t *); 460 extern void async_remote_state_release_exchange(async_exch_t *); 461 479 462 #endif 480 463 -
uspace/lib/c/include/bool.h
r867e2555 r925a21e 37 37 38 38 #include <libarch/types.h> 39 #include <abi/bool.h> 39 40 40 41 #define false 0 41 42 #define true 1 42 43 typedef uint8_t bool;44 43 45 44 #endif -
uspace/lib/c/include/ddi.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include < kernel/ddi/irq.h>39 #include <abi/ddi/irq.h> 40 40 #include <task.h> 41 41 -
uspace/lib/c/include/devman.h
r867e2555 r925a21e 38 38 39 39 #include <ipc/devman.h> 40 #include <ipc/loc.h> 40 41 #include <async.h> 41 42 #include <bool.h> … … 48 49 extern int devman_add_function(const char *, fun_type_t, match_id_list_t *, 49 50 devman_handle_t, devman_handle_t *); 51 extern int devman_remove_function(devman_handle_t); 52 extern int devman_drv_fun_online(devman_handle_t); 53 extern int devman_drv_fun_offline(devman_handle_t); 50 54 51 55 extern async_sess_t *devman_device_connect(exch_mgmt_t, devman_handle_t, … … 54 58 unsigned int); 55 59 56 extern int devman_ device_get_handle(const char *, devman_handle_t *,60 extern int devman_fun_get_handle(const char *, devman_handle_t *, 57 61 unsigned int); 58 extern int devman_device_get_handle_by_class(const char *, const char *, 59 devman_handle_t *, unsigned int); 60 extern int devman_get_device_path(devman_handle_t, char *, size_t); 62 extern int devman_fun_get_child(devman_handle_t, devman_handle_t *); 63 extern int devman_dev_get_functions(devman_handle_t, devman_handle_t **, 64 size_t *); 65 extern int devman_fun_get_name(devman_handle_t, char *, size_t); 66 extern int devman_fun_get_path(devman_handle_t, char *, size_t); 67 extern int devman_fun_online(devman_handle_t); 68 extern int devman_fun_offline(devman_handle_t); 61 69 62 extern int devman_add_device_to_class(devman_handle_t, const char *); 70 extern int devman_add_device_to_category(devman_handle_t, const char *); 71 extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *); 63 72 64 73 #endif -
uspace/lib/c/include/elf/elf.h
r867e2555 r925a21e 36 36 #define LIBC_ELF_H_ 37 37 38 #include <kernel/lib/elf.h> 38 #include <sys/types.h> 39 #include <abi/elf.h> 40 #include <libarch/elf.h> 39 41 40 42 #endif -
uspace/lib/c/include/elf/elf_load.h
r867e2555 r925a21e 38 38 #define ELF_LOAD_H_ 39 39 40 #include <arch/elf.h>41 40 #include <elf/elf.h> 42 41 #include <sys/types.h> … … 48 47 #define EE_OK 0 /* No error */ 49 48 #define EE_INVALID 1 /* Invalid ELF image */ 50 #define 49 #define EE_MEMORY 2 /* Cannot allocate address space */ 51 50 #define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */ 52 51 #define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */ -
uspace/lib/c/include/errno.h
r867e2555 r925a21e 36 36 #define LIBC_ERRNO_H_ 37 37 38 #include < kernel/errno.h>38 #include <abi/errno.h> 39 39 #include <fibril.h> 40 40 … … 55 55 #define EIO (-265) 56 56 #define EMLINK (-266) 57 #define ENXIO (-267) 57 58 58 59 /** Bad checksum. */ -
uspace/lib/c/include/event.h
r867e2555 r925a21e 36 36 #define LIBC_EVENT_H_ 37 37 38 #include <kernel/ipc/event_types.h> 38 #include <abi/ipc/event.h> 39 #include <libarch/types.h> 39 40 40 41 extern int event_subscribe(event_type_t, sysarg_t); 42 extern int event_task_subscribe(event_task_type_t, sysarg_t); 41 43 extern int event_unmask(event_type_t); 44 extern int event_task_unmask(event_task_type_t); 42 45 43 46 #endif -
uspace/lib/c/include/io/color.h
r867e2555 r925a21e 44 44 COLOR_MAGENTA = 5, 45 45 COLOR_YELLOW = 6, 46 COLOR_WHITE = 7, 47 48 CATTR_BRIGHT = 8, 49 CATTR_BLINK = 8 46 COLOR_WHITE = 7 50 47 } console_color_t; 48 49 typedef enum { 50 CATTR_NORMAL = 0, 51 CATTR_BRIGHT = 8, 52 CATTR_BLINK = 16 53 } console_color_attr_t; 51 54 52 55 #endif -
uspace/lib/c/include/io/console.h
r867e2555 r925a21e 37 37 38 38 #include <sys/time.h> 39 #include <io/keycode.h> 39 40 #include <async.h> 40 41 #include <bool.h> … … 42 43 43 44 typedef enum { 44 CONSOLE_C CAP_NONE = 0,45 CONSOLE_C CAP_STYLE,46 CONSOLE_C CAP_INDEXED,47 CONSOLE_C CAP_RGB45 CONSOLE_CAP_NONE = 0, 46 CONSOLE_CAP_STYLE = 1, 47 CONSOLE_CAP_INDEXED = 2, 48 CONSOLE_CAP_RGB = 4 48 49 } console_caps_t; 49 50 … … 76 77 /** Console event structure. */ 77 78 typedef struct { 79 /** List handle */ 80 link_t link; 81 78 82 /** Press or release event. */ 79 83 kbd_event_type_t type; 80 84 81 85 /** Keycode of the key that was pressed or released. */ 82 unsigned int key;86 keycode_t key; 83 87 84 88 /** Bitmask of modifiers held. */ 85 unsigned int mods;89 keymod_t mods; 86 90 87 91 /** The character that was generated or '\0' for none. */ -
uspace/lib/c/include/ipc/bd.h
r867e2555 r925a21e 42 42 BD_GET_NUM_BLOCKS, 43 43 BD_READ_BLOCKS, 44 BD_WRITE_BLOCKS 44 BD_WRITE_BLOCKS, 45 BD_READ_TOC 45 46 } bd_request_t; 46 47 -
uspace/lib/c/include/ipc/common.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include <abi/ipc/ipc.h> 39 40 #include <atomic.h> 40 #include < kernel/ipc/ipc.h>41 #include <task.h> 41 42 42 43 #define IPC_FLAG_BLOCKING 0x01 … … 44 45 typedef struct { 45 46 sysarg_t args[IPC_CALL_LEN]; 46 sysarg_t in_task_hash;47 task_id_t in_task_id; 47 48 sysarg_t in_phone_hash; 48 49 } ipc_call_t; -
uspace/lib/c/include/ipc/devman.h
r867e2555 r925a21e 130 130 DEVMAN_CLIENT, 131 131 DEVMAN_CONNECT_TO_DEVICE, 132 DEVMAN_CONNECT_FROM_ DEVMAP,132 DEVMAN_CONNECT_FROM_LOC, 133 133 DEVMAN_CONNECT_TO_PARENTS_DEVICE 134 134 } devman_interface_t; … … 138 138 DEVMAN_ADD_FUNCTION, 139 139 DEVMAN_ADD_MATCH_ID, 140 DEVMAN_ADD_DEVICE_TO_CLASS 141 140 DEVMAN_ADD_DEVICE_TO_CATEGORY, 141 DEVMAN_DRV_FUN_ONLINE, 142 DEVMAN_DRV_FUN_OFFLINE, 143 DEVMAN_REMOVE_FUNCTION 142 144 } driver_to_devman_t; 143 145 144 146 typedef enum { 145 DRIVER_ADD_DEVICE = IPC_FIRST_USER_METHOD 146 147 DRIVER_DEV_ADD = IPC_FIRST_USER_METHOD, 148 DRIVER_DEV_REMOVE, 149 DRIVER_DEV_GONE, 150 DRIVER_FUN_ONLINE, 151 DRIVER_FUN_OFFLINE, 147 152 } devman_to_driver_t; 148 153 149 154 typedef enum { 150 155 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS, 152 DEVMAN_DEVICE_GET_DEVICE_PATH 156 DEVMAN_DEV_GET_FUNCTIONS, 157 DEVMAN_FUN_GET_CHILD, 158 DEVMAN_FUN_GET_NAME, 159 DEVMAN_FUN_ONLINE, 160 DEVMAN_FUN_OFFLINE, 161 DEVMAN_FUN_GET_PATH, 162 DEVMAN_FUN_SID_TO_HANDLE 153 163 } client_to_devman_t; 154 164 -
uspace/lib/c/include/ipc/ipc.h
r867e2555 r925a21e 42 42 #include <sys/types.h> 43 43 #include <ipc/common.h> 44 #include < kernel/ipc/ipc_methods.h>45 #include < kernel/synch/synch.h>44 #include <abi/ipc/methods.h> 45 #include <abi/synch.h> 46 46 #include <task.h> 47 47 … … 254 254 sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool); 255 255 256 extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t *,256 extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, task_id_t *, 257 257 sysarg_t *); 258 258 extern int ipc_connect_me(int); -
uspace/lib/c/include/ipc/loc.h
r867e2555 r925a21e 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup devmap30 /** @addtogroup loc 30 31 * @{ 31 32 */ 32 33 33 #ifndef LIBC_IPC_ DEVMAP_H_34 #define LIBC_IPC_ DEVMAP_H_34 #ifndef LIBC_IPC_LOC_H_ 35 #define LIBC_IPC_LOC_H_ 35 36 36 37 #include <ipc/common.h> 37 38 38 #define DEVMAP_NAME_MAXLEN 25539 #define LOC_NAME_MAXLEN 255 39 40 40 typedef sysarg_t devmap_handle_t; 41 typedef sysarg_t service_id_t; 42 typedef sysarg_t category_id_t; 41 43 42 44 typedef enum { 43 DEV_HANDLE_NONE,44 DEV_HANDLE_NAMESPACE,45 DEV_HANDLE_DEVICE46 } devmap_handle_type_t;45 LOC_OBJECT_NONE, 46 LOC_OBJECT_NAMESPACE, 47 LOC_OBJECT_SERVICE 48 } loc_object_type_t; 47 49 48 50 typedef enum { 49 DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD, 50 DEVMAP_DRIVER_UNREGISTER, 51 DEVMAP_DEVICE_REGISTER, 52 DEVMAP_DEVICE_UNREGISTER, 53 DEVMAP_DEVICE_GET_HANDLE, 54 DEVMAP_NAMESPACE_GET_HANDLE, 55 DEVMAP_HANDLE_PROBE, 56 DEVMAP_NULL_CREATE, 57 DEVMAP_NULL_DESTROY, 58 DEVMAP_GET_NAMESPACE_COUNT, 59 DEVMAP_GET_DEVICE_COUNT, 60 DEVMAP_GET_NAMESPACES, 61 DEVMAP_GET_DEVICES 62 } devmap_request_t; 51 LOC_SERVER_REGISTER = IPC_FIRST_USER_METHOD, 52 LOC_SERVER_UNREGISTER, 53 LOC_SERVICE_ADD_TO_CAT, 54 LOC_SERVICE_REGISTER, 55 LOC_SERVICE_UNREGISTER, 56 LOC_SERVICE_GET_ID, 57 LOC_SERVICE_GET_NAME, 58 LOC_NAMESPACE_GET_ID, 59 LOC_CALLBACK_CREATE, 60 LOC_CATEGORY_GET_ID, 61 LOC_CATEGORY_GET_NAME, 62 LOC_CATEGORY_GET_SVCS, 63 LOC_ID_PROBE, 64 LOC_NULL_CREATE, 65 LOC_NULL_DESTROY, 66 LOC_GET_NAMESPACE_COUNT, 67 LOC_GET_SERVICE_COUNT, 68 LOC_GET_CATEGORIES, 69 LOC_GET_NAMESPACES, 70 LOC_GET_SERVICES 71 } loc_request_t; 63 72 64 /** Interface provided by devmap. 73 typedef enum { 74 LOC_EVENT_CAT_CHANGE = IPC_FIRST_USER_METHOD 75 } loc_event_t; 76 77 /** Ports provided by location service. 65 78 * 66 * Every process that connects to devmapmust ask one of following67 * interfacesotherwise connection will be refused.79 * Every process that connects to loc must ask one of following 80 * ports, otherwise connection will be refused. 68 81 * 69 82 */ 70 83 typedef enum { 71 /** Connect as device driver*/72 DEVMAP_DRIVER = 1,73 /** Connect as client */74 DEVMAP_CLIENT,84 /** Service supplier (server) port */ 85 LOC_PORT_SUPPLIER = 1, 86 /** Service consumer (client) port */ 87 LOC_PORT_CONSUMER, 75 88 /** Create new connection to instance of device that 76 89 is specified by second argument of call. */ 77 DEVMAP_CONNECT_TO_DEVICE78 } devmap_interface_t;90 LOC_CONNECT_TO_SERVICE 91 } loc_interface_t; 79 92 80 93 typedef struct { 81 devmap_handle_t handle;82 char name[ DEVMAP_NAME_MAXLEN + 1];83 } dev_desc_t;94 service_id_t id; 95 char name[LOC_NAME_MAXLEN + 1]; 96 } loc_sdesc_t; 84 97 85 98 #endif 99 100 /** @} 101 */ -
uspace/lib/c/include/ipc/services.h
r867e2555 r925a21e 43 43 SERVICE_NONE = 0, 44 44 SERVICE_LOAD = FOURCC('l', 'o', 'a', 'd'), 45 SERVICE_VIDEO = FOURCC('v', 'i', 'd', ' '),46 45 SERVICE_VFS = FOURCC('v', 'f', 's', ' '), 47 SERVICE_ DEVMAP = FOURCC('d', 'e', 'v', 'p'),46 SERVICE_LOC = FOURCC('l', 'o', 'c', ' '), 48 47 SERVICE_DEVMAN = FOURCC('d', 'e', 'v', 'n'), 49 48 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), -
uspace/lib/c/include/ipc/vfs.h
r867e2555 r925a21e 56 56 /** Unique identifier of the fs. */ 57 57 char name[FS_NAME_MAXLEN + 1]; 58 unsigned int instance; 58 59 bool concurrent_read_write; 59 60 bool write_retains_size; … … 62 63 typedef enum { 63 64 VFS_IN_OPEN = IPC_FIRST_USER_METHOD, 64 VFS_IN_OPEN_NODE,65 65 VFS_IN_READ, 66 66 VFS_IN_WRITE, … … 78 78 VFS_IN_RENAME, 79 79 VFS_IN_STAT, 80 VFS_IN_DUP 80 VFS_IN_DUP, 81 VFS_IN_WAIT_HANDLE, 81 82 } vfs_in_request_t; 82 83 -
uspace/lib/c/include/libc.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include < kernel/syscall/syscall.h>39 #include <abi/syscall.h> 40 40 #include <libarch/syscall.h> 41 41 -
uspace/lib/c/include/loader/loader.h
r867e2555 r925a21e 38 38 39 39 #include <task.h> 40 #include <vfs/vfs.h>41 40 42 41 /** Forward declararion */ … … 50 49 extern int loader_set_pathname(loader_t *, const char *); 51 50 extern int loader_set_args(loader_t *, const char *const[]); 52 extern int loader_set_files(loader_t *, fdi_node_t *const[]);51 extern int loader_set_files(loader_t *, int *const[]); 53 52 extern int loader_load_program(loader_t *); 54 53 extern int loader_run(loader_t *); -
uspace/lib/c/include/loader/pcb.h
r867e2555 r925a21e 38 38 39 39 #include <sys/types.h> 40 #include <vfs/vfs.h>41 40 42 41 typedef void (*entry_point_t)(void); … … 62 61 63 62 /** Number of preset files. */ 64 int filc; 65 /** Preset files. */ 66 fdi_node_t **filv; 63 unsigned int filc; 67 64 68 65 /* -
uspace/lib/c/include/rtld/elf_dyn.h
r867e2555 r925a21e 36 36 #define LIBC_RTLD_ELF_DYN_H_ 37 37 38 #include <arch/elf.h>39 38 #include <sys/types.h> 40 41 39 #include <elf/elf.h> 42 40 #include <libarch/rtld/elf_dyn.h> -
uspace/lib/c/include/stats.h
r867e2555 r925a21e 40 40 #include <stdint.h> 41 41 #include <bool.h> 42 #include <kernel/sysinfo/abi.h> 42 #include <sys/types.h> 43 #include <abi/sysinfo.h> 43 44 44 45 extern stats_cpu_t *stats_get_cpus(size_t *); -
uspace/lib/c/include/str.h
r867e2555 r925a21e 1 1 /* 2 2 * Copyright (c) 2005 Martin Decky 3 * Copyright (c) 2011 Oleg Romanenko 3 4 * All rights reserved. 4 5 * … … 83 84 extern char *wstr_to_astr(const wchar_t *src); 84 85 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src); 86 extern wchar_t *str_to_awstr(const char *src); 87 extern int utf16_to_str(char *dest, size_t size, const uint16_t *src); 88 extern int str_to_utf16(uint16_t *dest, size_t size, const char *src); 85 89 86 90 extern char *str_chr(const char *str, wchar_t ch); … … 93 97 extern char *str_ndup(const char *, size_t max_size); 94 98 99 extern int str_uint8_t(const char *, char **, unsigned int, bool, uint8_t *); 100 extern int str_uint16_t(const char *, char **, unsigned int, bool, uint16_t *); 101 extern int str_uint32_t(const char *, char **, unsigned int, bool, uint32_t *); 95 102 extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *); 96 103 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *); -
uspace/lib/c/include/sys/stat.h
r867e2555 r925a21e 39 39 #include <bool.h> 40 40 #include <ipc/vfs.h> 41 #include <ipc/ devmap.h>41 #include <ipc/loc.h> 42 42 43 43 struct stat { 44 44 fs_handle_t fs_handle; 45 devmap_handle_t devmap_handle;45 service_id_t service_id; 46 46 fs_index_t index; 47 47 unsigned int lnkcnt; … … 49 49 bool is_directory; 50 50 aoff64_t size; 51 devmap_handle_t device;51 service_id_t service; 52 52 }; 53 53 -
uspace/lib/c/include/syscall.h
r867e2555 r925a21e 45 45 46 46 #include <sys/types.h> 47 #include < kernel/syscall/syscall.h>47 #include <abi/syscall.h> 48 48 49 49 #define __syscall0 __syscall -
uspace/lib/c/include/sysinfo.h
r867e2555 r925a21e 36 36 #define LIBC_SYSINFO_H_ 37 37 38 #include <libc.h> 38 #include <sys/types.h> 39 #include <bool.h> 40 #include <abi/sysinfo.h> 39 41 40 /** Sysinfo value types 41 * 42 */ 43 typedef enum { 44 SYSINFO_VAL_UNDEFINED = 0, 45 SYSINFO_VAL_VAL = 1, 46 SYSINFO_VAL_DATA = 2 47 } sysinfo_item_tag_t; 48 49 extern sysinfo_item_tag_t sysinfo_get_tag(const char *); 42 extern sysinfo_item_val_type_t sysinfo_get_val_type(const char *); 50 43 extern int sysinfo_get_value(const char *, sysarg_t *); 51 44 extern void *sysinfo_get_data(const char *, size_t *); -
uspace/lib/c/include/task.h
r867e2555 r925a21e 37 37 38 38 #include <sys/types.h> 39 #include <vfs/vfs.h> 40 41 typedef uint64_t task_id_t; 39 #include <abi/proc/task.h> 42 40 43 41 typedef enum { … … 53 51 extern int task_spawnv(task_id_t *, const char *path, const char *const []); 54 52 extern int task_spawnvf(task_id_t *, const char *path, const char *const [], 55 fdi_node_t *const []);53 int *const []); 56 54 extern int task_spawnl(task_id_t *, const char *path, ...); 57 55 -
uspace/lib/c/include/thread.h
r867e2555 r925a21e 38 38 #include <libarch/thread.h> 39 39 #include <sys/types.h> 40 41 typedef uint64_t thread_id_t; 40 #include <abi/proc/thread.h> 42 41 43 42 extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *); -
uspace/lib/c/include/udebug.h
r867e2555 r925a21e 36 36 #define LIBC_UDEBUG_H_ 37 37 38 #include < kernel/udebug/udebug.h>38 #include <abi/udebug.h> 39 39 #include <sys/types.h> 40 40 #include <async.h> -
uspace/lib/c/include/vfs/vfs.h
r867e2555 r925a21e 38 38 #include <sys/types.h> 39 39 #include <ipc/vfs.h> 40 #include <ipc/ devmap.h>40 #include <ipc/loc.h> 41 41 #include <stdio.h> 42 #include <async.h> 42 43 43 /** Libc version of the VFS triplet. 44 * 45 * Unique identification of a file system node 46 * within a file system instance. 47 * 48 */ 49 typedef struct { 50 fs_handle_t fs_handle; 51 devmap_handle_t devmap_handle; 52 fs_index_t index; 53 } fdi_node_t; 44 enum vfs_change_state_type { 45 VFS_PASS_HANDLE 46 }; 54 47 55 48 extern char *absolutize(const char *, size_t *); 56 49 57 50 extern int mount(const char *, const char *, const char *, const char *, 58 unsigned int );51 unsigned int, unsigned int); 59 52 extern int unmount(const char *); 60 53 61 extern int open_node(fdi_node_t *, int); 62 extern int fd_node(int, fdi_node_t *); 54 extern int fhandle(FILE *, int *); 63 55 64 extern FILE *fopen_node(fdi_node_t *, const char *); 65 extern int fnode(FILE *, fdi_node_t *); 56 extern int fd_wait(void); 57 58 extern async_exch_t *vfs_exchange_begin(void); 59 extern void vfs_exchange_end(async_exch_t *); 66 60 67 61 #endif
Note:
See TracChangeset
for help on using the changeset viewer.