Changeset bd5f3b7 in mainline for uspace/lib/c/arch/ia32/include/elf_linux.h
- Timestamp:
- 2011-08-21T13:07:35Z (13 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.