diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-03-27 04:14:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:44:37 -0500 |
commit | 63ae2a94d98dd9d94163918539ec80df33f44a69 (patch) | |
tree | ebb7d6d0919fd5a8d3bac6c6a726f2f51f53f779 /arch/um/os-Linux | |
parent | d9f8b62a6b033fe7226d7c2b2efdd164ca1aa07c (diff) |
[PATCH] uml: move libc-dependent irq code to os-Linux
The serial UML OS-abstraction layer patch (um/kernel dir).
This moves all systemcalls from irq_user.c file under os-Linux dir
Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/Makefile | 6 | ||||
-rw-r--r-- | arch/um/os-Linux/irq.c | 162 | ||||
-rw-r--r-- | arch/um/os-Linux/tt.c | 10 |
3 files changed, 175 insertions, 3 deletions
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 08a4e628b24c..73d3d837ed6b 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile | |||
@@ -3,14 +3,14 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ | 6 | obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o signal.o \ |
7 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o user_syms.o \ | 7 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o user_syms.o \ |
8 | util.o drivers/ sys-$(SUBARCH)/ | 8 | util.o drivers/ sys-$(SUBARCH)/ |
9 | 9 | ||
10 | obj-$(CONFIG_MODE_SKAS) += skas/ | 10 | obj-$(CONFIG_MODE_SKAS) += skas/ |
11 | 11 | ||
12 | USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ | 12 | USER_OBJS := aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o \ |
13 | start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o util.o | 13 | signal.o start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o util.o |
14 | 14 | ||
15 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h | 15 | elf_aux.o: $(ARCH_DIR)/kernel-offsets.h |
16 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um | 16 | CFLAGS_elf_aux.o += -I$(objtree)/arch/um |
diff --git a/arch/um/os-Linux/irq.c b/arch/um/os-Linux/irq.c new file mode 100644 index 000000000000..e599be423da1 --- /dev/null +++ b/arch/um/os-Linux/irq.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #include <stdlib.h> | ||
7 | #include <unistd.h> | ||
8 | #include <errno.h> | ||
9 | #include <signal.h> | ||
10 | #include <string.h> | ||
11 | #include <sys/poll.h> | ||
12 | #include <sys/types.h> | ||
13 | #include <sys/time.h> | ||
14 | #include "user_util.h" | ||
15 | #include "kern_util.h" | ||
16 | #include "user.h" | ||
17 | #include "process.h" | ||
18 | #include "sigio.h" | ||
19 | #include "irq_user.h" | ||
20 | #include "os.h" | ||
21 | |||
22 | static struct pollfd *pollfds = NULL; | ||
23 | static int pollfds_num = 0; | ||
24 | static int pollfds_size = 0; | ||
25 | |||
26 | int os_waiting_for_events(struct irq_fd *active_fds) | ||
27 | { | ||
28 | struct irq_fd *irq_fd; | ||
29 | int i, n, err; | ||
30 | |||
31 | n = poll(pollfds, pollfds_num, 0); | ||
32 | if(n < 0){ | ||
33 | err = -errno; | ||
34 | if(errno != EINTR) | ||
35 | printk("sigio_handler: os_waiting_for_events:" | ||
36 | " poll returned %d, errno = %d\n", n, errno); | ||
37 | return err; | ||
38 | } | ||
39 | |||
40 | if(n == 0) | ||
41 | return 0; | ||
42 | |||
43 | irq_fd = active_fds; | ||
44 | |||
45 | for(i = 0; i < pollfds_num; i++){ | ||
46 | if(pollfds[i].revents != 0){ | ||
47 | irq_fd->current_events = pollfds[i].revents; | ||
48 | pollfds[i].fd = -1; | ||
49 | } | ||
50 | irq_fd = irq_fd->next; | ||
51 | } | ||
52 | return n; | ||
53 | } | ||
54 | |||
55 | int os_isatty(int fd) | ||
56 | { | ||
57 | return(isatty(fd)); | ||
58 | } | ||
59 | |||
60 | int os_create_pollfd(int fd, int events, void *tmp_pfd, int size_tmpfds) | ||
61 | { | ||
62 | if (pollfds_num == pollfds_size) { | ||
63 | if (size_tmpfds <= pollfds_size * sizeof(pollfds[0])) { | ||
64 | /* return min size needed for new pollfds area */ | ||
65 | return((pollfds_size + 1) * sizeof(pollfds[0])); | ||
66 | } | ||
67 | |||
68 | if(pollfds != NULL){ | ||
69 | memcpy(tmp_pfd, pollfds, | ||
70 | sizeof(pollfds[0]) * pollfds_size); | ||
71 | /* remove old pollfds */ | ||
72 | kfree(pollfds); | ||
73 | } | ||
74 | pollfds = tmp_pfd; | ||
75 | pollfds_size++; | ||
76 | } else { | ||
77 | /* remove not used tmp_pfd */ | ||
78 | if (tmp_pfd != NULL) | ||
79 | kfree(tmp_pfd); | ||
80 | } | ||
81 | |||
82 | pollfds[pollfds_num] = ((struct pollfd) { .fd = fd, | ||
83 | .events = events, | ||
84 | .revents = 0 }); | ||
85 | pollfds_num++; | ||
86 | |||
87 | return(0); | ||
88 | } | ||
89 | |||
90 | void os_free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg, | ||
91 | struct irq_fd *active_fds, struct irq_fd ***last_irq_ptr2) | ||
92 | { | ||
93 | struct irq_fd **prev; | ||
94 | int i = 0; | ||
95 | |||
96 | prev = &active_fds; | ||
97 | while(*prev != NULL){ | ||
98 | if((*test)(*prev, arg)){ | ||
99 | struct irq_fd *old_fd = *prev; | ||
100 | if((pollfds[i].fd != -1) && | ||
101 | (pollfds[i].fd != (*prev)->fd)){ | ||
102 | printk("os_free_irq_by_cb - mismatch between " | ||
103 | "active_fds and pollfds, fd %d vs %d\n", | ||
104 | (*prev)->fd, pollfds[i].fd); | ||
105 | goto out; | ||
106 | } | ||
107 | |||
108 | pollfds_num--; | ||
109 | |||
110 | /* This moves the *whole* array after pollfds[i] | ||
111 | * (though it doesn't spot as such)! | ||
112 | */ | ||
113 | |||
114 | memmove(&pollfds[i], &pollfds[i + 1], | ||
115 | (pollfds_num - i) * sizeof(pollfds[0])); | ||
116 | if(*last_irq_ptr2 == &old_fd->next) | ||
117 | *last_irq_ptr2 = prev; | ||
118 | |||
119 | *prev = (*prev)->next; | ||
120 | if(old_fd->type == IRQ_WRITE) | ||
121 | ignore_sigio_fd(old_fd->fd); | ||
122 | kfree(old_fd); | ||
123 | continue; | ||
124 | } | ||
125 | prev = &(*prev)->next; | ||
126 | i++; | ||
127 | } | ||
128 | out: | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | |||
133 | int os_get_pollfd(int i) | ||
134 | { | ||
135 | return(pollfds[i].fd); | ||
136 | } | ||
137 | |||
138 | void os_set_pollfd(int i, int fd) | ||
139 | { | ||
140 | pollfds[i].fd = fd; | ||
141 | } | ||
142 | |||
143 | void os_set_ioignore(void) | ||
144 | { | ||
145 | set_handler(SIGIO, SIG_IGN, 0, -1); | ||
146 | } | ||
147 | |||
148 | void init_irq_signals(int on_sigstack) | ||
149 | { | ||
150 | __sighandler_t h; | ||
151 | int flags; | ||
152 | |||
153 | flags = on_sigstack ? SA_ONSTACK : 0; | ||
154 | if(timer_irq_inited) h = (__sighandler_t) alarm_handler; | ||
155 | else h = boot_timer_handler; | ||
156 | |||
157 | set_handler(SIGVTALRM, h, flags | SA_RESTART, | ||
158 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, -1); | ||
159 | set_handler(SIGIO, (__sighandler_t) sig_handler, flags | SA_RESTART, | ||
160 | SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); | ||
161 | signal(SIGWINCH, SIG_IGN); | ||
162 | } | ||
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c index 919d19f11537..5461a065bbb9 100644 --- a/arch/um/os-Linux/tt.c +++ b/arch/um/os-Linux/tt.c | |||
@@ -110,6 +110,16 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay) | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void forward_ipi(int fd, int pid) | ||
114 | { | ||
115 | int err; | ||
116 | |||
117 | err = os_set_owner(fd, pid); | ||
118 | if(err < 0) | ||
119 | printk("forward_ipi: set_owner failed, fd = %d, me = %d, " | ||
120 | "target = %d, err = %d\n", fd, os_getpid(), pid, -err); | ||
121 | } | ||
122 | |||
113 | /* | 123 | /* |
114 | *------------------------- | 124 | *------------------------- |
115 | * only for tt mode (will be deleted in future...) | 125 | * only for tt mode (will be deleted in future...) |