Changeset bd5f3b7 in mainline for uspace/lib/c
- Timestamp:
- 2011-08-21T13:07:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00aece0, f1a9e87
- Parents:
- 86a34d3e (diff), a6480d5 (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:
-
- 49 added
- 2 deleted
- 74 edited
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
r86a34d3e rbd5f3b7 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 … … 59 58 -include arch/$(UARCH)/Makefile.inc 60 59 61 EXTRA_CFLAGS += -I../../srv/loader/include62 63 60 GENERIC_SOURCES = \ 64 61 generic/libc.c \ … … 67 64 generic/cap.c \ 68 65 generic/clipboard.c \ 69 generic/devmap.c \70 66 generic/devman.c \ 71 67 generic/device/hw_res.c \ 72 68 generic/device/char_dev.c \ 69 generic/elf/elf_load.c \ 73 70 generic/event.c \ 74 71 generic/errno.c \ 72 generic/loc.c \ 75 73 generic/mem.c \ 76 74 generic/str.c \ … … 134 132 generic/dlfcn.c \ 135 133 generic/rtld/rtld.c \ 136 generic/rtld/elf_load.c \137 134 generic/rtld/dynamic.c \ 138 135 generic/rtld/module.c \ … … 146 143 include $(USPACE_PREFIX)/Makefile.common 147 144 148 $(INCLUDE_ARCH): $(INCLUDE_KERNEL) $(INCLUDE_KERNEL)/arch149 ln -sfn kernel/arch $@150 151 145 $(INCLUDE_LIBARCH): arch/$(UARCH)/include 152 146 ln -sfn ../$< $@ 153 147 154 $(INCLUDE_KERNEL)/arch: ../../../kernel/generic/include/arch $(INCLUDE_KERNEL) 155 156 $(INCLUDE_KERNEL): ../../../kernel/generic/include/ 148 $(INCLUDE_ABI): ../../../abi/include/ 157 149 ln -sfn ../$< $@ 158 150 -
uspace/lib/c/arch/abs32le/include/elf_linux.h
r86a34d3e rbd5f3b7 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup drvusbmast29 /** @addtogroup libcabs32le 30 30 * @{ 31 31 */ 32 32 /** @file 33 * Generic functions for USB mass storage.34 33 */ 35 34 36 #ifndef USB_USBMAST_MAST_H_37 #define USB_USBMAST_MAST_H_35 #ifndef LIBC_abs32le_ELF_LINUX_H_ 36 #define LBIC_abs32le_ELF_LINUX_H_ 38 37 39 #include < scsi/spc.h>38 #include <libarch/istate.h> 40 39 #include <sys/types.h> 41 #include <usb/usb.h>42 #include <usb/dev/pipes.h>43 #include <usb/dev/driver.h>44 40 45 #define BULK_IN_EP 0 46 #define BULK_OUT_EP 1 41 typedef struct { 42 } elf_regs_t; 47 43 48 int usb_massstor_data_in(usb_device_t *dev, uint32_t, uint8_t, void *, 49 size_t, void *, size_t, size_t *); 50 int usb_massstor_reset(usb_device_t *); 51 void usb_massstor_reset_recovery(usb_device_t *); 52 int usb_massstor_get_max_lun(usb_device_t *); 53 size_t usb_masstor_get_lun_count(usb_device_t *); 44 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 45 { 46 (void) istate; (void) elf_regs; 47 } 54 48 55 49 #endif 56 50 57 /** 58 * @} 51 /** @} 59 52 */ -
uspace/lib/c/arch/abs32le/include/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/amd64/include/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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/src/fibril.S
r86a34d3e rbd5f3b7 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/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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/ia32/Makefile.common
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/ddi.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup tester 30 * @brief Test devman service. 29 /** @addtogroup libcia32 31 30 * @{ 32 31 */ 33 /** 34 * @file 32 /** @file Definitions needed to write core files in Linux-ELF format. 35 33 */ 36 34 37 #include <inttypes.h> 38 #include <errno.h> 39 #include <str_error.h> 35 #ifndef LIBC_ia32_ELF_LINUX_H_ 36 #define LBIC_ia32_ELF_LINUX_H_ 37 38 #include <libarch/istate.h> 40 39 #include <sys/types.h> 41 #include <async.h>42 #include <devman.h>43 #include <str.h>44 #include <async.h>45 #include <vfs/vfs.h>46 #include <vfs/vfs_sess.h>47 #include <sys/stat.h>48 #include <fcntl.h>49 #include "../tester.h"50 40 51 #define DEVICE_CLASS "test3" 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 */ 46 typedef struct { 47 uint32_t ebx; 48 uint32_t ecx; 49 uint32_t edx; 50 uint32_t esi; 51 uint32_t edi; 52 uint32_t ebp; 53 uint32_t eax; 54 uint32_t ds; 55 uint32_t es; 56 uint32_t fs; 57 uint32_t gs; 58 uint32_t old_eax; 59 uint32_t eip; 60 uint32_t cs; 61 uint32_t eflags; 62 uint32_t esp; 63 uint32_t ss; 64 } elf_regs_t; 52 65 53 const char *test_devman2(void) 66 /** Convert istate_t to elf_regs_t. */ 67 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 54 68 { 55 size_t idx = 1; 56 int rc = EOK; 57 const char *err_msg = NULL; 58 char *path = NULL; 59 while (rc == EOK) { 60 rc = asprintf(&path, "/dev/class/%s\\%zu", DEVICE_CLASS, idx); 61 if (rc < 0) { 62 continue; 63 } 64 int fd = open(path, O_RDONLY); 65 if (fd < 0) { 66 TPRINTF("Failed opening `%s': %s.\n", 67 path, str_error(fd)); 68 rc = fd; 69 err_msg = "Failed opening file"; 70 continue; 71 } 72 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 73 close(fd); 74 if (sess == NULL) { 75 TPRINTF("Failed opening phone: %s.\n", str_error(errno)); 76 rc = errno; 77 err_msg = "Failed opening file descriptor phone"; 78 continue; 79 } 80 async_hangup(sess); 81 TPRINTF("Path `%s' okay.\n", path); 82 free(path); 83 idx++; 84 rc = EOK; 85 } 86 87 if (path != NULL) 88 free(path); 89 90 return err_msg; 69 elf_regs->ebx = istate->ebx; 70 elf_regs->ecx = istate->ecx; 71 elf_regs->edx = istate->edx; 72 elf_regs->esi = istate->esi; 73 elf_regs->edi = istate->edi; 74 elf_regs->ebp = istate->ebp; 75 elf_regs->eax = istate->eax; 76 77 elf_regs->ds = istate->ds; 78 elf_regs->es = istate->es; 79 elf_regs->fs = istate->fs; 80 elf_regs->gs = istate->gs; 81 82 elf_regs->old_eax = 0; 83 elf_regs->eip = istate->eip; 84 elf_regs->cs = istate->cs; 85 elf_regs->eflags = istate->eflags; 86 elf_regs->esp = istate->esp; 87 elf_regs->ss = istate->ss; 91 88 } 89 90 #endif 92 91 93 92 /** @} -
uspace/lib/c/arch/ia32/include/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/src/entry.S
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/mips32/include/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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/src/fibril.S
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/src/fibril.S
r86a34d3e rbd5f3b7 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/istate.h
-
Property mode
changed from
100644
to120000
r86a34d3e rbd5f3b7 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/src/fibril.S
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/src/fibril.S
r86a34d3e rbd5f3b7 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/async.c
r86a34d3e rbd5f3b7 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 … … 138 139 link_t link; 139 140 140 sysarg_t in_task_hash;141 task_id_t in_task_id; 141 142 atomic_t refcnt; 142 143 void *data; … … 150 151 link_t link; 151 152 152 /** Incoming client task hash. */153 sysarg_t in_task_hash;153 /** Incoming client task ID. */ 154 task_id_t in_task_id; 154 155 155 156 /** Incoming phone hash. */ … … 203 204 } 204 205 205 void *async_get_client_data(void)206 {207 assert(fibril_connection);208 return fibril_connection->client->data;209 }210 211 206 /** Default fibril function that gets called to handle new connection. 212 207 * … … 289 284 { 290 285 assert(key); 286 assert(keys == 2); 291 287 assert(item); 292 288 293 289 client_t *client = hash_table_get_instance(item, client_t, link); 294 return (key[0] == client->in_task_hash); 290 return (key[0] == LOWER32(client->in_task_id) && 291 (key[1] == UPPER32(client->in_task_id))); 295 292 } 296 293 … … 580 577 } 581 578 579 static client_t *async_client_get(task_id_t client_id, bool create) 580 { 581 unsigned long key[2] = { 582 LOWER32(client_id), 583 UPPER32(client_id), 584 }; 585 client_t *client = NULL; 586 587 futex_down(&async_futex); 588 link_t *lnk = hash_table_find(&client_hash_table, key); 589 if (lnk) { 590 client = hash_table_get_instance(lnk, client_t, link); 591 atomic_inc(&client->refcnt); 592 } else if (create) { 593 client = malloc(sizeof(client_t)); 594 if (client) { 595 client->in_task_id = client_id; 596 client->data = async_client_data_create(); 597 598 atomic_set(&client->refcnt, 1); 599 hash_table_insert(&client_hash_table, key, &client->link); 600 } 601 } 602 603 futex_up(&async_futex); 604 return client; 605 } 606 607 static void async_client_put(client_t *client) 608 { 609 bool destroy; 610 unsigned long key[2] = { 611 LOWER32(client->in_task_id), 612 UPPER32(client->in_task_id) 613 }; 614 615 futex_down(&async_futex); 616 617 if (atomic_predec(&client->refcnt) == 0) { 618 hash_table_remove(&client_hash_table, key, 2); 619 destroy = true; 620 } else 621 destroy = false; 622 623 futex_up(&async_futex); 624 625 if (destroy) { 626 if (client->data) 627 async_client_data_destroy(client->data); 628 629 free(client); 630 } 631 } 632 633 void *async_get_client_data(void) 634 { 635 assert(fibril_connection); 636 return fibril_connection->client->data; 637 } 638 639 void *async_get_client_data_by_id(task_id_t client_id) 640 { 641 client_t *client = async_client_get(client_id, false); 642 if (!client) 643 return NULL; 644 if (!client->data) { 645 async_client_put(client); 646 return NULL; 647 } 648 649 return client->data; 650 } 651 652 void async_put_client_data_by_id(task_id_t client_id) 653 { 654 client_t *client = async_client_get(client_id, false); 655 656 assert(client); 657 assert(client->data); 658 659 /* Drop the reference we got in async_get_client_data_by_hash(). */ 660 async_client_put(client); 661 662 /* Drop our own reference we got at the beginning of this function. */ 663 async_client_put(client); 664 } 665 582 666 /** Wrapper for client connection fibril. 583 667 * … … 598 682 */ 599 683 fibril_connection = (connection_t *) arg; 600 601 futex_down(&async_futex);602 684 603 685 /* … … 606 688 * hash in a new tracking structure. 607 689 */ 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 690 691 client_t *client = async_client_get(fibril_connection->in_task_id, true); 692 if (!client) { 693 ipc_answer_0(fibril_connection->callid, ENOMEM); 694 return 0; 695 } 696 634 697 fibril_connection->client = client; 635 698 … … 643 706 * Remove the reference for this client task connection. 644 707 */ 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 } 708 async_client_put(client); 663 709 664 710 /* … … 666 712 */ 667 713 futex_down(&async_futex); 668 key = fibril_connection->in_phone_hash;714 unsigned long key = fibril_connection->in_phone_hash; 669 715 hash_table_remove(&conn_hash_table, &key, 1); 670 716 futex_up(&async_futex); … … 700 746 * particular fibrils. 701 747 * 702 * @param in_task_ hashIdentification of the incoming connection.748 * @param in_task_id Identification of the incoming connection. 703 749 * @param in_phone_hash Identification of the incoming connection. 704 750 * @param callid Hash of the opening IPC_M_CONNECT_ME_TO call. … … 714 760 * 715 761 */ 716 fid_t async_new_connection( sysarg_t in_task_hash, sysarg_t in_phone_hash,762 fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash, 717 763 ipc_callid_t callid, ipc_call_t *call, 718 764 async_client_conn_t cfibril, void *carg) … … 726 772 } 727 773 728 conn->in_task_ hash = in_task_hash;774 conn->in_task_id = in_task_id; 729 775 conn->in_phone_hash = in_phone_hash; 730 776 list_initialize(&conn->msg_queue); … … 785 831 case IPC_M_CONNECT_ME_TO: 786 832 /* Open new connection with fibril, etc. */ 787 async_new_connection(call->in_task_ hash, IPC_GET_ARG5(*call),833 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call), 788 834 callid, call, client_connection, NULL); 789 835 return; … … 933 979 { 934 980 if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 935 1, &client_hash_table_ops))981 2, &client_hash_table_ops)) 936 982 abort(); 937 983 … … 949 995 session_ns->arg2 = 0; 950 996 session_ns->arg3 = 0; 997 998 fibril_mutex_initialize(&session_ns->remote_state_mtx); 999 session_ns->remote_state_data = NULL; 951 1000 952 1001 list_initialize(&session_ns->exch_list); … … 1426 1475 return ENOENT; 1427 1476 1428 sysarg_t task_hash;1429 1477 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); 1478 sysarg_t rc; 1479 1480 aid_t req; 1481 ipc_call_t answer; 1482 req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1483 &answer); 1484 async_wait_for(req, &rc); 1432 1485 if (rc != EOK) 1433 return rc; 1434 1486 return (int) rc; 1487 1488 phone_hash = IPC_GET_ARG5(answer); 1489 1435 1490 if (client_receiver != NULL) 1436 async_new_connection( task_hash, phone_hash, 0, NULL,1491 async_new_connection(answer.in_task_id, phone_hash, 0, NULL, 1437 1492 client_receiver, carg); 1438 1493 … … 1509 1564 sess->arg3 = 0; 1510 1565 1566 fibril_mutex_initialize(&sess->remote_state_mtx); 1567 sess->remote_state_data = NULL; 1568 1511 1569 list_initialize(&sess->exch_list); 1512 1570 fibril_mutex_initialize(&sess->mutex); … … 1590 1648 sess->arg3 = arg3; 1591 1649 1650 fibril_mutex_initialize(&sess->remote_state_mtx); 1651 sess->remote_state_data = NULL; 1652 1592 1653 list_initialize(&sess->exch_list); 1593 1654 fibril_mutex_initialize(&sess->mutex); … … 1595 1656 1596 1657 return sess; 1658 } 1659 1660 /** Set arguments for new connections. 1661 * 1662 * FIXME This is an ugly hack to work around the problem that parallel 1663 * exchanges are implemented using parallel connections. When we create 1664 * a callback session, the framework does not know arguments for the new 1665 * connections. 1666 * 1667 * The proper solution seems to be to implement parallel exchanges using 1668 * tagging. 1669 */ 1670 void async_sess_args_set(async_sess_t *sess, sysarg_t arg1, sysarg_t arg2, 1671 sysarg_t arg3) 1672 { 1673 sess->arg1 = arg1; 1674 sess->arg2 = arg2; 1675 sess->arg3 = arg3; 1597 1676 } 1598 1677 … … 1640 1719 sess->arg3 = arg3; 1641 1720 1721 fibril_mutex_initialize(&sess->remote_state_mtx); 1722 sess->remote_state_data = NULL; 1723 1642 1724 list_initialize(&sess->exch_list); 1643 1725 fibril_mutex_initialize(&sess->mutex); … … 1670 1752 sess->arg2 = 0; 1671 1753 sess->arg3 = 0; 1754 1755 fibril_mutex_initialize(&sess->remote_state_mtx); 1756 sess->remote_state_data = NULL; 1672 1757 1673 1758 list_initialize(&sess->exch_list); … … 2334 2419 sess->arg3 = 0; 2335 2420 2421 fibril_mutex_initialize(&sess->remote_state_mtx); 2422 sess->remote_state_data = NULL; 2423 2336 2424 list_initialize(&sess->exch_list); 2337 2425 fibril_mutex_initialize(&sess->mutex); … … 2380 2468 sess->arg3 = 0; 2381 2469 2470 fibril_mutex_initialize(&sess->remote_state_mtx); 2471 sess->remote_state_data = NULL; 2472 2382 2473 list_initialize(&sess->exch_list); 2383 2474 fibril_mutex_initialize(&sess->mutex); … … 2422 2513 sess->arg3 = 0; 2423 2514 2515 fibril_mutex_initialize(&sess->remote_state_mtx); 2516 sess->remote_state_data = NULL; 2517 2424 2518 list_initialize(&sess->exch_list); 2425 2519 fibril_mutex_initialize(&sess->mutex); … … 2429 2523 } 2430 2524 2525 int async_state_change_start(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2, 2526 sysarg_t arg3, async_exch_t *other_exch) 2527 { 2528 return async_req_5_0(exch, IPC_M_STATE_CHANGE_AUTHORIZE, 2529 arg1, arg2, arg3, 0, other_exch->phone); 2530 } 2531 2532 bool async_state_change_receive(ipc_callid_t *callid, sysarg_t *arg1, 2533 sysarg_t *arg2, sysarg_t *arg3) 2534 { 2535 assert(callid); 2536 2537 ipc_call_t call; 2538 *callid = async_get_call(&call); 2539 2540 if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE) 2541 return false; 2542 2543 if (arg1) 2544 *arg1 = IPC_GET_ARG1(call); 2545 if (arg2) 2546 *arg2 = IPC_GET_ARG2(call); 2547 if (arg3) 2548 *arg3 = IPC_GET_ARG3(call); 2549 2550 return true; 2551 } 2552 2553 int async_state_change_finalize(ipc_callid_t callid, async_exch_t *other_exch) 2554 { 2555 return ipc_answer_1(callid, EOK, other_exch->phone); 2556 } 2557 2558 /** Lock and get session remote state 2559 * 2560 * Lock and get the local replica of the remote state 2561 * in stateful sessions. The call should be paired 2562 * with async_remote_state_release*(). 2563 * 2564 * @param[in] sess Stateful session. 2565 * 2566 * @return Local replica of the remote state. 2567 * 2568 */ 2569 void *async_remote_state_acquire(async_sess_t *sess) 2570 { 2571 fibril_mutex_lock(&sess->remote_state_mtx); 2572 return sess->remote_state_data; 2573 } 2574 2575 /** Update the session remote state 2576 * 2577 * Update the local replica of the remote state 2578 * in stateful sessions. The remote state must 2579 * be already locked. 2580 * 2581 * @param[in] sess Stateful session. 2582 * @param[in] state New local replica of the remote state. 2583 * 2584 */ 2585 void async_remote_state_update(async_sess_t *sess, void *state) 2586 { 2587 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2588 sess->remote_state_data = state; 2589 } 2590 2591 /** Release the session remote state 2592 * 2593 * Unlock the local replica of the remote state 2594 * in stateful sessions. 2595 * 2596 * @param[in] sess Stateful session. 2597 * 2598 */ 2599 void async_remote_state_release(async_sess_t *sess) 2600 { 2601 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2602 2603 fibril_mutex_unlock(&sess->remote_state_mtx); 2604 } 2605 2606 /** Release the session remote state and end an exchange 2607 * 2608 * Unlock the local replica of the remote state 2609 * in stateful sessions. This is convenience function 2610 * which gets the session pointer from the exchange 2611 * and also ends the exchange. 2612 * 2613 * @param[in] exch Stateful session's exchange. 2614 * 2615 */ 2616 void async_remote_state_release_exchange(async_exch_t *exch) 2617 { 2618 if (exch == NULL) 2619 return; 2620 2621 async_sess_t *sess = exch->sess; 2622 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2623 2624 async_exchange_end(exch); 2625 fibril_mutex_unlock(&sess->remote_state_mtx); 2626 } 2627 2431 2628 /** @} 2432 2629 */ -
uspace/lib/c/generic/async_obsolete.c
r86a34d3e rbd5f3b7 38 38 #include <async.h> 39 39 #include <async_obsolete.h> 40 #include "private/async.h" 40 41 #undef LIBC_ASYNC_C_ 41 42 #undef LIBC_ASYNC_OBSOLETE_C_ … … 44 45 #include <malloc.h> 45 46 #include <errno.h> 46 #include "private/async.h"47 47 48 48 /** Send message and return id of the sent message. -
uspace/lib/c/generic/ddi.c
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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 310 329 async_sess_t *devman_parent_device_connect(exch_mgmt_t mgmt, 311 330 devman_handle_t handle, unsigned int flags) … … 323 342 } 324 343 325 int devman_ device_get_handle(const char *pathname, devman_handle_t *handle,344 int devman_fun_get_handle(const char *pathname, devman_handle_t *handle, 326 345 unsigned int flags) 327 346 { … … 333 352 exch = devman_exchange_begin(DEVMAN_CLIENT); 334 353 if (exch == NULL) 335 return errno;354 return ENOMEM; 336 355 } 337 356 … … 364 383 } 365 384 366 int devman_device_get_handle_by_class(const char *classname,367 const char *devname, devman_handle_t *handle, unsigned int flags)385 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf, 386 size_t buf_size) 368 387 { 369 388 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 } 389 ipc_call_t dreply; 390 size_t act_size; 391 sysarg_t dretval; 392 393 exch = devman_exchange_begin_blocking(LOC_PORT_CONSUMER); 378 394 379 395 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)); 396 aid_t req = async_send_1(exch, method, arg1, &answer); 397 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 398 async_wait_for(dreq, &dretval); 399 400 devman_exchange_end(exch); 401 402 if (dretval != EOK) { 403 async_wait_for(req, NULL); 404 return dretval; 405 } 406 407 sysarg_t retval; 408 async_wait_for(req, &retval); 409 410 if (retval != EOK) 411 return retval; 412 413 act_size = IPC_GET_ARG2(dreply); 414 assert(act_size <= buf_size - 1); 415 buf[act_size] = '\0'; 416 417 return EOK; 418 } 419 420 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 421 { 422 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 423 buf_size); 424 } 425 426 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 427 { 428 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 429 buf_size); 430 } 431 432 static int devman_get_handles_once(sysarg_t method, sysarg_t arg1, 433 devman_handle_t *handle_buf, size_t buf_size, size_t *act_size) 434 { 435 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_CLIENT); 436 437 ipc_call_t answer; 438 aid_t req = async_send_1(exch, method, arg1, &answer); 439 int rc = async_data_read_start(exch, handle_buf, buf_size); 440 441 devman_exchange_end(exch); 442 443 if (rc != EOK) { 444 async_wait_for(req, NULL); 445 return rc; 446 } 447 448 sysarg_t retval; 449 async_wait_for(req, &retval); 384 450 385 451 if (retval != EOK) { 386 devman_exchange_end(exch); 387 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 401 async_wait_for(req, &retval); 402 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) 452 return retval; 453 } 454 455 *act_size = IPC_GET_ARG1(answer); 456 return EOK; 457 } 458 459 /** Get list of handles. 460 * 461 * Returns an allocated array of handles. 462 * 463 * @param method IPC method 464 * @param arg1 IPC argument 1 465 * @param data Place to store pointer to array of handles 466 * @param count Place to store number of handles 467 * @return EOK on success or negative error code 468 */ 469 static int devman_get_handles_internal(sysarg_t method, sysarg_t arg1, 470 devman_handle_t **data, size_t *count) 471 { 472 devman_handle_t *handles; 473 size_t act_size; 474 size_t alloc_size; 475 int rc; 476 477 *data = NULL; 478 act_size = 0; /* silence warning */ 479 480 rc = devman_get_handles_once(method, arg1, NULL, 0, 481 &act_size); 482 if (rc != EOK) 483 return rc; 484 485 alloc_size = act_size; 486 handles = malloc(alloc_size); 487 if (handles == NULL) 488 return ENOMEM; 489 490 while (true) { 491 rc = devman_get_handles_once(method, arg1, handles, alloc_size, 492 &act_size); 493 if (rc != EOK) 494 return rc; 495 496 if (act_size <= alloc_size) 497 break; 498 499 alloc_size *= 2; 500 free(handles); 501 502 handles = malloc(alloc_size); 503 if (handles == NULL) 504 return ENOMEM; 505 } 506 507 *count = act_size / sizeof(devman_handle_t); 508 *data = handles; 509 return EOK; 510 } 511 512 int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh) 417 513 { 418 514 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 419 515 if (exch == NULL) 420 return errno;421 422 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) {433 async_wait_for(req, NULL);434 516 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; 462 return EOK; 517 518 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_GET_CHILD, 519 funh, devh); 520 521 devman_exchange_end(exch); 522 return (int) retval; 523 } 524 525 int devman_dev_get_functions(devman_handle_t devh, devman_handle_t **funcs, 526 size_t *count) 527 { 528 return devman_get_handles_internal(DEVMAN_DEV_GET_FUNCTIONS, 529 devh, funcs, count); 530 } 531 532 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 533 { 534 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 535 if (exch == NULL) 536 return ENOMEM; 537 538 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE, 539 sid, handle); 540 541 devman_exchange_end(exch); 542 return (int) retval; 463 543 } 464 544 -
uspace/lib/c/generic/elf/elf_load.c
r86a34d3e rbd5f3b7 29 29 */ 30 30 31 /** @addtogroup generic 31 /** @addtogroup generic 32 32 * @{ 33 33 */ … … 49 49 #include <assert.h> 50 50 #include <as.h> 51 #include <elf/elf.h> 51 52 #include <unistd.h> 52 53 #include <fcntl.h> … … 55 56 #include <entry_point.h> 56 57 57 #include "elf.h" 58 #include "elf_load.h" 58 #include <elf/elf_load.h> 59 59 60 60 #define DPRINTF(...) … … 74 74 static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry); 75 75 76 /** Read until the buffer is read in its entirety. */77 static int my_read(int fd, void *buf, size_t len)78 {79 int cnt = 0;80 do {81 buf += cnt;82 len -= cnt;83 cnt = read(fd, buf, len);84 } while ((cnt > 0) && ((len - cnt) > 0));85 86 return cnt;87 }88 89 76 /** Load ELF binary from a file. 90 77 * … … 160 147 int i, rc; 161 148 162 rc = my_read(elf->fd, header, sizeof(elf_header_t));163 if (rc < 0) {149 rc = read_all(elf->fd, header, sizeof(elf_header_t)); 150 if (rc != sizeof(elf_header_t)) { 164 151 DPRINTF("Read error.\n"); 165 152 return EE_INVALID; … … 222 209 + i * sizeof(elf_segment_header_t), SEEK_SET); 223 210 224 rc = my_read(elf->fd, &segment_hdr,211 rc = read_all(elf->fd, &segment_hdr, 225 212 sizeof(elf_segment_header_t)); 226 if (rc < 0) {213 if (rc != sizeof(elf_segment_header_t)) { 227 214 DPRINTF("Read error.\n"); 228 215 return EE_INVALID; … … 244 231 + i * sizeof(elf_section_header_t), SEEK_SET); 245 232 246 rc = my_read(elf->fd, §ion_hdr,233 rc = read_all(elf->fd, §ion_hdr, 247 234 sizeof(elf_section_header_t)); 248 if (rc < 0) {235 if (rc != sizeof(elf_section_header_t)) { 249 236 DPRINTF("Read error.\n"); 250 237 return EE_INVALID; … … 334 321 uintptr_t seg_addr; 335 322 size_t mem_sz; 336 int rc;323 ssize_t rc; 337 324 338 325 bias = elf->bias; … … 412 399 if (now > left) now = left; 413 400 414 rc = my_read(elf->fd, dp, now);415 416 if (rc < 0) {401 rc = read_all(elf->fd, dp, now); 402 403 if (rc != (ssize_t) now) { 417 404 DPRINTF("Read error.\n"); 418 405 return EE_INVALID; -
uspace/lib/c/generic/event.c
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/io.c
r86a34d3e rbd5f3b7 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 { … … 594 562 } 595 563 596 buf+= now;564 data += now; 597 565 stream->buf_head += now; 598 566 buf_free -= now; 599 567 bytes_left -= now; 600 568 total_written += now; 569 stream->buf_state = _bs_write; 601 570 602 571 if (buf_free == 0) { … … 606 575 } 607 576 } 608 609 if (total_written > 0)610 stream->buf_state = _bs_write;611 577 612 578 if (need_flush) … … 714 680 off64_t ftell(FILE *stream) 715 681 { 682 _fflushbuf(stream); 716 683 return lseek(stream->fd, 0, SEEK_CUR); 717 684 } … … 781 748 } 782 749 783 int fnode(FILE *stream, fdi_node_t *node) 784 { 785 if (stream->fd >= 0) 786 return fd_node(stream->fd, node); 750 int fhandle(FILE *stream, int *handle) 751 { 752 if (stream->fd >= 0) { 753 *handle = stream->fd; 754 return EOK; 755 } 787 756 788 757 return ENOENT; -
uspace/lib/c/generic/io/printf_core.c
r86a34d3e rbd5f3b7 206 206 } 207 207 208 return (int) (counter + 1);208 return (int) (counter); 209 209 } 210 210 … … 244 244 } 245 245 246 return (int) (counter + 1);246 return (int) (counter); 247 247 } 248 248 -
uspace/lib/c/generic/ipc.c
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/ns.c
r86a34d3e rbd5f3b7 56 56 async_exchange_end(exch); 57 57 58 /* 59 * FIXME Ugly hack to work around limitation of implementing 60 * parallel exchanges using multiple connections. Shift out 61 * first argument for non-initial connections. 62 */ 63 async_sess_args_set(sess, arg2, arg3, 0); 64 58 65 return sess; 59 66 } … … 66 73 async_connect_me_to_blocking(mgmt, exch, service, arg2, arg3); 67 74 async_exchange_end(exch); 75 76 /* 77 * FIXME Ugly hack to work around limitation of implementing 78 * parallel exchanges using multiple connections. Shift out 79 * first argument for non-initial connections. 80 */ 81 async_sess_args_set(sess, arg2, arg3, 0); 68 82 69 83 return sess; -
uspace/lib/c/generic/ns_obsolete.c
r86a34d3e rbd5f3b7 36 36 #include <async_obsolete.h> 37 37 #include <ns_obsolete.h> 38 #include < kernel/ipc/ipc_methods.h>38 #include <abi/ipc/methods.h> 39 39 40 40 int service_obsolete_connect(sysarg_t service, sysarg_t arg2, sysarg_t arg3) -
uspace/lib/c/generic/private/async.h
r86a34d3e rbd5f3b7 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> 44 45 /** Session data */ 46 struct _async_sess { 47 /** List of inactive exchanges */ 48 list_t exch_list; 49 50 /** Exchange management style */ 51 exch_mgmt_t mgmt; 52 53 /** Session identification */ 54 int phone; 55 56 /** First clone connection argument */ 57 sysarg_t arg1; 58 59 /** Second clone connection argument */ 60 sysarg_t arg2; 61 62 /** Third clone connection argument */ 63 sysarg_t arg3; 64 65 /** Exchange mutex */ 66 fibril_mutex_t mutex; 67 68 /** Number of opened exchanges */ 69 atomic_t refcnt; 70 71 /** Mutex for stateful connections */ 72 fibril_mutex_t remote_state_mtx; 73 74 /** Data for stateful connections */ 75 void *remote_state_data; 76 }; 77 78 /** Exchange data */ 79 struct _async_exch { 80 /** Link into list of inactive exchanges */ 81 link_t sess_link; 82 83 /** Link into global list of inactive exchanges */ 84 link_t global_link; 85 86 /** Session pointer */ 87 async_sess_t *sess; 88 89 /** Exchange identification */ 90 int phone; 91 }; 42 92 43 93 /** Structures of this type are used to track the timeout events. */ -
uspace/lib/c/generic/private/io.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/rtld/module.c
r86a34d3e rbd5f3b7 35 35 */ 36 36 37 #include <adt/list.h> 38 #include <elf/elf_load.h> 39 #include <fcntl.h> 40 #include <loader/pcb.h> 37 41 #include <stdio.h> 38 42 #include <stdlib.h> 39 43 #include <unistd.h> 40 #include <fcntl.h>41 #include <adt/list.h>42 #include <loader/pcb.h>43 44 44 45 #include <rtld/rtld.h> … … 47 48 #include <rtld/rtld_arch.h> 48 49 #include <rtld/module.h> 49 #include <elf_load.h>50 50 51 51 /** (Eagerly) process all relocation tables in a module. … … 93 93 module_t *module_find(const char *name) 94 94 { 95 link_t *head = &runtime_env->modules_head;96 97 link_t *cur;98 95 module_t *m; 99 96 const char *p, *soname; … … 110 107 111 108 /* Traverse list of all modules. Not extremely fast, but simple */ 112 DPRINTF("head = %p\n", head); 113 for (cur = head->next; cur != head; cur = cur->next) { 109 list_foreach(runtime_env->modules, cur) { 114 110 DPRINTF("cur = %p\n", cur); 115 111 m = list_get_instance(cur, module_t, modules_link); … … 177 173 178 174 /* Insert into the list of loaded modules */ 179 list_append(&m->modules_link, &runtime_env->modules _head);175 list_append(&m->modules_link, &runtime_env->modules); 180 176 181 177 return m; … … 249 245 void modules_process_relocs(module_t *start) 250 246 { 251 link_t *head = &runtime_env->modules_head; 252 253 link_t *cur; 254 module_t *m; 255 256 for (cur = head->next; cur != head; cur = cur->next) { 247 module_t *m; 248 249 list_foreach(runtime_env->modules, cur) { 257 250 m = list_get_instance(cur, module_t, modules_link); 258 251 … … 268 261 void modules_untag(void) 269 262 { 270 link_t *head = &runtime_env->modules_head; 271 272 link_t *cur; 273 module_t *m; 274 275 for (cur = head->next; cur != head; cur = cur->next) { 263 module_t *m; 264 265 list_foreach(runtime_env->modules, cur) { 276 266 m = list_get_instance(cur, module_t, modules_link); 277 267 m->bfs_tag = false; -
uspace/lib/c/generic/rtld/rtld.c
r86a34d3e rbd5f3b7 44 44 { 45 45 runtime_env = &rt_env_static; 46 list_initialize(&runtime_env->modules _head);46 list_initialize(&runtime_env->modules); 47 47 runtime_env->next_bias = 0x2000000; 48 48 runtime_env->program = NULL; -
uspace/lib/c/generic/rtld/symbol.c
r86a34d3e rbd5f3b7 38 38 #include <stdlib.h> 39 39 40 #include <elf/elf.h> 40 41 #include <rtld/rtld.h> 41 42 #include <rtld/rtld_debug.h> 42 43 #include <rtld/symbol.h> 43 #include <elf.h>44 44 45 45 /* … … 118 118 module_t *m, *dm; 119 119 elf_symbol_t *sym, *s; 120 li nk_t queue_head;120 list_t queue; 121 121 size_t i; 122 122 … … 132 132 133 133 /* Insert root (the program) into the queue and tag it */ 134 list_initialize(&queue _head);134 list_initialize(&queue); 135 135 start->bfs_tag = true; 136 list_append(&start->queue_link, &queue _head);136 list_append(&start->queue_link, &queue); 137 137 138 138 /* If the symbol is found, it will be stored in 'sym' */ … … 140 140 141 141 /* While queue is not empty */ 142 while (!list_empty(&queue _head)) {142 while (!list_empty(&queue)) { 143 143 /* Pop first element from the queue */ 144 m = list_get_instance( queue_head.next, module_t, queue_link);144 m = list_get_instance(list_first(&queue), module_t, queue_link); 145 145 list_remove(&m->queue_link); 146 146 … … 162 162 if (dm->bfs_tag == false) { 163 163 dm->bfs_tag = true; 164 list_append(&dm->queue_link, &queue _head);164 list_append(&dm->queue_link, &queue); 165 165 } 166 166 } … … 168 168 169 169 /* Empty the queue so that we leave it in a clean state */ 170 while (!list_empty(&queue _head))171 list_remove( queue_head.next);170 while (!list_empty(&queue)) 171 list_remove(list_first(&queue)); 172 172 173 173 if (!sym) { -
uspace/lib/c/generic/str.c
r86a34d3e rbd5f3b7 2 2 * Copyright (c) 2005 Martin Decky 3 3 * Copyright (c) 2008 Jiri Svoboda 4 * Copyright (c) 2011 Martin Sucha 4 5 * All rights reserved. 5 6 * … … 718 719 719 720 dest[dlen - 1] = '\0'; 721 } 722 723 /** Convert string to wide string. 724 * 725 * Convert string @a src to wide string. A new wide NULL-terminated 726 * string will be allocated on the heap. 727 * 728 * @param src Source string. 729 */ 730 wchar_t *str_to_awstr(const char *str) 731 { 732 size_t len = str_length(str); 733 wchar_t *wstr = calloc(len+1, sizeof(wchar_t)); 734 if (wstr == NULL) { 735 return NULL; 736 } 737 str_to_wstr(wstr, len+1, str); 738 return wstr; 720 739 } 721 740 -
uspace/lib/c/generic/task.c
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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,144 int mount(const char *fs_name, const char *mp, const char *fqsn, 145 145 const char *opts, unsigned int flags) 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_2(exch, VFS_IN_MOUNT, service_id, flags, NULL); 184 184 sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size); 185 185 if (rc != EOK) { … … 189 189 190 190 if (null_id != -1) 191 devmap_null_destroy(null_id);191 loc_null_destroy(null_id); 192 192 193 193 if (rc_orig == EOK) … … 204 204 205 205 if (null_id != -1) 206 devmap_null_destroy(null_id);206 loc_null_destroy(null_id); 207 207 208 208 if (rc_orig == EOK) … … 219 219 220 220 if (null_id != -1) 221 devmap_null_destroy(null_id);221 loc_null_destroy(null_id); 222 222 223 223 if (rc_orig == EOK) … … 235 235 236 236 if (null_id != -1) 237 devmap_null_destroy(null_id);237 loc_null_destroy(null_id); 238 238 239 239 if (rc_orig == EOK) … … 248 248 249 249 if ((rc != EOK) && (null_id != -1)) 250 devmap_null_destroy(null_id);250 loc_null_destroy(null_id); 251 251 252 252 return (int) rc; … … 329 329 } 330 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 }349 350 331 int close(int fildes) 351 332 { … … 415 396 else 416 397 return -1; 398 } 399 400 /** Read entire buffer. 401 * 402 * In face of short reads this function continues reading until either 403 * the entire buffer is read or no more data is available (at end of file). 404 * 405 * @param fildes File descriptor 406 * @param buf Buffer, @a nbytes bytes long 407 * @param nbytes Number of bytes to read 408 * 409 * @return On success, positive number of bytes read. 410 * On failure, negative error code from read(). 411 */ 412 ssize_t read_all(int fildes, void *buf, size_t nbyte) 413 { 414 ssize_t cnt = 0; 415 size_t nread = 0; 416 uint8_t *bp = (uint8_t *) buf; 417 418 do { 419 bp += cnt; 420 nread += cnt; 421 cnt = read(fildes, bp, nbyte - nread); 422 } while (cnt > 0 && (nbyte - nread - cnt) > 0); 423 424 if (cnt < 0) 425 return cnt; 426 427 return nread + cnt; 428 } 429 430 /** Write entire buffer. 431 * 432 * This function fails if it cannot write exactly @a len bytes to the file. 433 * 434 * @param fildes File descriptor 435 * @param buf Data, @a nbytes bytes long 436 * @param nbytes Number of bytes to write 437 * 438 * @return EOK on error, return value from write() if writing 439 * failed. 440 */ 441 ssize_t write_all(int fildes, const void *buf, size_t nbyte) 442 { 443 ssize_t cnt = 0; 444 ssize_t nwritten = 0; 445 const uint8_t *bp = (uint8_t *) buf; 446 447 do { 448 bp += cnt; 449 nwritten += cnt; 450 cnt = write(fildes, bp, nbyte - nwritten); 451 } while (cnt > 0 && ((ssize_t )nbyte - nwritten - cnt) > 0); 452 453 if (cnt < 0) 454 return cnt; 455 456 if ((ssize_t)nbyte - nwritten - cnt > 0) 457 return EIO; 458 459 return nbyte; 417 460 } 418 461 … … 749 792 } 750 793 751 if (!stat. device) {794 if (!stat.service) { 752 795 errno = ENOENT; 753 796 return NULL; 754 797 } 755 798 756 return devmap_device_connect(mgmt, stat.device, 0); 757 } 758 759 int fd_node(int fildes, fdi_node_t *node) 760 { 761 struct stat stat; 762 int rc = fstat(fildes, &stat); 763 764 if (rc == EOK) { 765 node->fs_handle = stat.fs_handle; 766 node->devmap_handle = stat.devmap_handle; 767 node->index = stat.index; 768 } 769 770 return rc; 799 return loc_service_connect(mgmt, stat.service, 0); 771 800 } 772 801 … … 786 815 } 787 816 817 int fd_wait(void) 818 { 819 async_exch_t *exch = vfs_exchange_begin(); 820 821 sysarg_t ret; 822 sysarg_t rc = async_req_0_1(exch, VFS_IN_WAIT_HANDLE, &ret); 823 824 vfs_exchange_end(exch); 825 826 if (rc == EOK) 827 return (int) ret; 828 829 return (int) rc; 830 } 831 788 832 /** @} 789 833 */ -
uspace/lib/c/include/as.h
r86a34d3e rbd5f3b7 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 -
uspace/lib/c/include/async.h
r86a34d3e rbd5f3b7 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/ddi.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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); 50 52 51 53 extern async_sess_t *devman_device_connect(exch_mgmt_t, devman_handle_t, … … 54 56 unsigned int); 55 57 56 extern int devman_ device_get_handle(const char *, devman_handle_t *,58 extern int devman_fun_get_handle(const char *, devman_handle_t *, 57 59 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); 60 extern int devman_fun_get_child(devman_handle_t, devman_handle_t *); 61 extern int devman_dev_get_functions(devman_handle_t, devman_handle_t **, 62 size_t *); 63 extern int devman_fun_get_name(devman_handle_t, char *, size_t); 64 extern int devman_fun_get_path(devman_handle_t, char *, size_t); 61 65 62 extern int devman_add_device_to_class(devman_handle_t, const char *); 66 extern int devman_add_device_to_category(devman_handle_t, const char *); 67 extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *); 63 68 64 69 #endif -
uspace/lib/c/include/elf/elf.h
r86a34d3e rbd5f3b7 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #ifndef FB_PPM_H_ 30 #define FB_PPM_H_ 29 /** @addtogroup generic 30 * @{ 31 */ 32 /** @file 33 */ 31 34 32 #include "fb.h" 35 #ifndef LIBC_ELF_H_ 36 #define LIBC_ELF_H_ 37 33 38 #include <sys/types.h> 34 35 extern int ppm_draw(unsigned char *, size_t, unsigned int, unsigned int, 36 unsigned int, unsigned int, putpixel_cb_t, void *); 37 extern int ppm_get_data(unsigned char *, size_t, unsigned int *, unsigned int *); 39 #include <abi/elf.h> 40 #include <libarch/elf.h> 38 41 39 42 #endif 43 44 /** @} 45 */ -
uspace/lib/c/include/elf/elf_load.h
r86a34d3e rbd5f3b7 1 1 /* 2 * Copyright (c) 2006 Sergey Bondari 2 3 * Copyright (c) 2008 Jiri Svoboda 3 4 * All rights reserved. … … 37 38 #define ELF_LOAD_H_ 38 39 39 #include < arch/elf.h>40 #include <elf/elf.h> 40 41 #include <sys/types.h> 41 42 #include <loader/pcb.h> 42 43 43 #include "elf.h" 44 /** 45 * ELF error return codes 46 */ 47 #define EE_OK 0 /* No error */ 48 #define EE_INVALID 1 /* Invalid ELF image */ 49 #define EE_MEMORY 2 /* Cannot allocate address space */ 50 #define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */ 51 #define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */ 52 #define EE_LOADER 5 /* The image is actually a program loader. */ 53 #define EE_IRRECOVERABLE 6 44 54 45 55 typedef enum { … … 82 92 } elf_ld_t; 83 93 84 int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags, 85 elf_info_t *info);86 void elf_create_pcb(elf_info_t *info, pcb_t *pcb);94 extern const char *elf_error(unsigned int); 95 extern int elf_load_file(const char *, size_t, eld_flags_t, elf_info_t *); 96 extern void elf_create_pcb(elf_info_t *, pcb_t *); 87 97 88 98 #endif -
uspace/lib/c/include/errno.h
r86a34d3e rbd5f3b7 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 -
uspace/lib/c/include/event.h
r86a34d3e rbd5f3b7 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/ipc/common.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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_C LASS141 140 DEVMAN_ADD_DEVICE_TO_CATEGORY, 141 DEVMAN_REMOVE_FUNCTION 142 142 } driver_to_devman_t; 143 143 … … 149 149 typedef enum { 150 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS, 152 DEVMAN_DEVICE_GET_DEVICE_PATH 151 DEVMAN_DEV_GET_FUNCTIONS, 152 DEVMAN_FUN_GET_CHILD, 153 DEVMAN_FUN_GET_NAME, 154 DEVMAN_FUN_GET_PATH, 155 DEVMAN_FUN_SID_TO_HANDLE 153 156 } client_to_devman_t; 154 157 -
uspace/lib/c/include/ipc/fb.h
r86a34d3e rbd5f3b7 55 55 FB_DRAW_TEXT_DATA, 56 56 FB_FLUSH, 57 FB_DRAW_ PPM,57 FB_DRAW_IMGMAP, 58 58 FB_PREPARE_SHM, 59 59 FB_DROP_SHM, 60 FB_SHM2 PIXMAP,61 FB_VP_DRAW_ PIXMAP,62 FB_VP2 PIXMAP,63 FB_DROP_ PIXMAP,60 FB_SHM2IMGMAP, 61 FB_VP_DRAW_IMGMAP, 62 FB_VP2IMGMAP, 63 FB_DROP_IMGMAP, 64 64 FB_ANIM_CREATE, 65 65 FB_ANIM_DROP, 66 FB_ANIM_ADD PIXMAP,66 FB_ANIM_ADDIMGMAP, 67 67 FB_ANIM_CHGVP, 68 68 FB_ANIM_START, -
uspace/lib/c/include/ipc/ipc.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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 -
uspace/lib/c/include/ipc/services.h
r86a34d3e rbd5f3b7 45 45 SERVICE_VIDEO = FOURCC('v', 'i', 'd', ' '), 46 46 SERVICE_VFS = FOURCC('v', 'f', 's', ' '), 47 SERVICE_ DEVMAP = FOURCC('d', 'e', 'v', 'p'),47 SERVICE_LOC = FOURCC('l', 'o', 'c', ' '), 48 48 SERVICE_DEVMAN = FOURCC('d', 'e', 'v', 'n'), 49 49 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), -
uspace/lib/c/include/ipc/vfs.h
r86a34d3e rbd5f3b7 62 62 typedef enum { 63 63 VFS_IN_OPEN = IPC_FIRST_USER_METHOD, 64 VFS_IN_OPEN_NODE,65 64 VFS_IN_READ, 66 65 VFS_IN_WRITE, … … 78 77 VFS_IN_RENAME, 79 78 VFS_IN_STAT, 80 VFS_IN_DUP 79 VFS_IN_DUP, 80 VFS_IN_WAIT_HANDLE, 81 81 } vfs_in_request_t; 82 82 -
uspace/lib/c/include/libc.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 36 36 #define LIBC_RTLD_ELF_DYN_H_ 37 37 38 #include <arch/elf.h>39 38 #include <sys/types.h> 40 41 #include <elf.h> 39 #include <elf/elf.h> 42 40 #include <libarch/rtld/elf_dyn.h> 43 41 -
uspace/lib/c/include/rtld/rtld.h
r86a34d3e rbd5f3b7 49 49 50 50 /** List of all loaded modules including rtld and the program */ 51 li nk_t modules_head;51 list_t modules; 52 52 53 53 /** Temporary hack to place each module at different address. */ -
uspace/lib/c/include/rtld/symbol.h
r86a34d3e rbd5f3b7 36 36 #define LIBC_RTLD_SYMBOL_H_ 37 37 38 #include <elf/elf.h> 38 39 #include <rtld/rtld.h> 39 #include <elf.h>40 40 41 41 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod); -
uspace/lib/c/include/stats.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 83 83 extern char *wstr_to_astr(const wchar_t *src); 84 84 extern void str_to_wstr(wchar_t *dest, size_t dlen, const char *src); 85 extern wchar_t *str_to_awstr(const char *src); 85 86 86 87 extern char *str_chr(const char *str, wchar_t ch); -
uspace/lib/c/include/sys/stat.h
r86a34d3e rbd5f3b7 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
r86a34d3e rbd5f3b7 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/task.h
r86a34d3e rbd5f3b7 37 37 38 38 #include <sys/types.h> 39 #include <vfs/vfs.h>40 39 41 40 typedef uint64_t task_id_t; … … 53 52 extern int task_spawnv(task_id_t *, const char *path, const char *const []); 54 53 extern int task_spawnvf(task_id_t *, const char *path, const char *const [], 55 fdi_node_t *const []);54 int *const []); 56 55 extern int task_spawnl(task_id_t *, const char *path, ...); 57 56 -
uspace/lib/c/include/udebug.h
r86a34d3e rbd5f3b7 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/unistd.h
r86a34d3e rbd5f3b7 63 63 extern ssize_t read(int, void *, size_t); 64 64 65 extern ssize_t read_all(int, void *, size_t); 66 extern ssize_t write_all(int, const void *, size_t); 67 65 68 extern off64_t lseek(int, off64_t, int); 66 69 extern int ftruncate(int, aoff64_t); -
uspace/lib/c/include/vfs/vfs.h
r86a34d3e rbd5f3b7 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 *); … … 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.