summaryrefslogtreecommitdiff
path: root/i386/include
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gnu.org>2007-05-07 22:04:54 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-06-18 00:27:10 +0200
commit2c1f7f5ef7e2252312ecfa77b2352e89669006bf (patch)
tree503d5b28de51384b4789b75a8ec506132c795349 /i386/include
parent029ea3ffa9e56d33eef2e859c98848f722f63b1c (diff)
2007-05-07 Thomas Schwinge <tschwinge@gnu.org>
[bug #15295 --- ``Mach lets processes write to I/O ports''] * i386/Makefrag.am (libkernel_a_SOURCES): Add `i386/i386/io_perm.c', `i386/i386/io_perm.h', `i386/i386/machine_task.c', `i386/i386/task.h' and remove `i386/i386/io_port.h', `i386/i386/iopb.c', `i386/i386/iopb.h'. * i386/i386/io_port.h: Remove file. * i386/i386at/kd.c: Don't include <i386/io_port.h>. (vga_port_list, kd_io_device, kd_io_map_open, kd_io_map_close): Don't define and don't use anymore. * include/stddef.h: New file. * i386/i386/io_perm.c: Include <string.h>, <device/device_emul.h>, <ipc/ipc_space.h> and don't include <oskit/ds_oskit.h>. (io_perm_device_emulation_ops): New variable. (dev_open_alloc, setup_no_senders): Remove declarations. (convert_io_perm_to_port, convert_port_to_io_perm, io_perm_deallocate): Rewrite. (no_senders): New function. (i386_io_perm_create, i386_io_perm_modify): Rewrite partially, to adapt to the GNU Mach environment. * i386/i386/io_perm.h: Include <device/dev_hdr.h> and <ipc/ipc_types.h>. (io_perm, io_perm_t): New structure and accompanying type definition. (IO_PERM_NULL): Define. * i386/i386/locore.S (ktss): Move variable to... * i386/i386/ktss.c: ... here, make it a ``struct task_tss''. (ktss_init): Initialize the `task_tss' structure and the i/o permission bit map. * i386/i386/ktss.h: Adapt to that. * i386/i386/machine_task.c (machine_task_module_init): Adapt the `zinit' call to the GNU Mach environment. * i386/i386/mp_desc.c: Include <machine/ktss.h>. * i386/i386/tss.h: Include <machine/io_perm.h>. (task_tss): New structure, equivalent to the OSKit-Mach one. * i386/include/mach/i386/mach_i386.defs: Don't include <device/device_types.defs>. (device_list_t): Remove type. * i386/include/mach/i386/mach_i386_types.h (device_list_t): Remove type definition. 2007-05-07 Marcus Brinkmann <marcus@gnu.org> [bug #15295 --- ``Mach lets processes write to I/O ports''] * i386/i386/iopb.h, i386/i386/iopb.c: Obsolete files removed. * i386/i386/pcb.c (switch_context): Update the I/O permission bitmap from stack_handoff() here (not only in stack_handoff()). * i386/i386/machine_task.c (machine_task_module_init): Set ZONE_COLLECTABLE and ZONE_EXHAUSTIBLE flags for the iopb zone. Requested by Roland McGrath <roland@frob.com>. * i386/i386/io_perm.h: New file. * i386/i386/io_perm.c: New file. * i386/i386/machine_task.c: New file. * i386/i386/mp_desc.h: (struct mp_desc_table): Change type of ktss to struct task_tss. (mp_ktss): Likewise for array of pointers to the struct. * i386/i386/mp_desc.c: Include `machine/tss.h' and `machine/io_perm.h'. (mp_ktss): Change type to array of struct task_tss. (mp_desc_init): Cast pointer to x86_tss into pointer to task_tss, and use size of struct task_tss instead size of struct x86_tss. Initialize the task_tss structure. * i386/i386/pcb.c: Include `stddef.h' and `machine/tss.h'. (iopb_create, iopb_destroy): Prototypes removed. (curr_ktss): Cast pointer to base_tss to pointer to struct task_tss. (switch_ktss): Always use kernel TSS. (update_ktss_iopb): New function. (stack_handoff): Call update_ktss_iopb. (pcb_module_init): Do not call iopb_init. (pcb_terminate): Do not call iopb_destroy. (thread_setstatus): Remove local variable tss. (thread_getstatus): Rewrite i386_ISA_PORT_MAP_STATE case handler. * i386/i386/task.h: New file. * i386/i386/thread.h: Do not include `i386/iopb.h'. (struct i386_machine_state): Remove member io_tss. * i386/include/mach/i386/mach_i386.defs [KERNEL_SERVER]: Include `machine/io_perm.h'. Define intran, outtran and destructor. (io_port_t): New type. (io_perm_t): Likewise. (i386_io_port_add): Interface removed. (i386_io_port_remove): Likewise. (i386_io_port_list): Likewise. (i386_io_perm_create): New interface. (i386_io_perm_modify): Likewise. * i386/include/mach/i386/mach_i386_types.h [MACH_KERNEL]: Include `i386/io_perm.h'. [!MACH_KERNEL]: Define types io_port_t and io_perm_t. * kern/task.c (task_init): Call machine_task_module_init. (task_create): Call machine_task_init. (task_deallocate): Call machine_task_terminate. (task_collect_scan): Call machine_task_collect. * task.h: Include `machine/task.h'. (struct task): Add member machine.
Diffstat (limited to 'i386/include')
-rw-r--r--i386/include/mach/i386/mach_i386.defs52
-rw-r--r--i386/include/mach/i386/mach_i386_types.h16
2 files changed, 49 insertions, 19 deletions
diff --git a/i386/include/mach/i386/mach_i386.defs b/i386/include/mach/i386/mach_i386.defs
index 5c9f367..0703d59 100644
--- a/i386/include/mach/i386/mach_i386.defs
+++ b/i386/include/mach/i386/mach_i386.defs
@@ -35,26 +35,31 @@ subsystem
#include <mach/std_types.defs>
#include <mach/mach_types.defs>
-#include <device/device_types.defs>
-
-type device_list_t = ^array[] of device_t;
type descriptor_t = struct[2] of int;
type descriptor_list_t = array[*] of descriptor_t;
import <mach/machine/mach_i386_types.h>;
-routine i386_io_port_add(
- target_thread : thread_t;
- device : device_t);
+#if KERNEL_SERVER
+simport <machine/io_perm.h>;
+#endif
-routine i386_io_port_remove(
- target_thread : thread_t;
- device : device_t);
+type io_port_t = MACH_MSG_TYPE_INTEGER_16;
+type io_perm_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: io_perm_t convert_port_to_io_perm(mach_port_t)
+ outtran: mach_port_t convert_io_perm_to_port(io_perm_t)
+#if TODO_REMOVE_ME
+ destructor: io_perm_deallocate(io_perm_t)
+#endif
+#endif /* KERNEL_SERVER */
+ ;
-routine i386_io_port_list(
- target_thread : thread_t;
- out device_list : device_list_t);
+skip; /* i386_io_port_add */
+skip; /* i386_io_port_remove */
+skip; /* i386_io_port_list */
routine i386_set_ldt(
target_thread : thread_t;
@@ -67,8 +72,27 @@ routine i386_get_ldt(
selector_count : int;
out desc_list : descriptor_list_t);
-skip; /* i386_io_perm_create */
-skip; /* i386_io_perm_modify */
+/* Request a new port IO_PERM that represents the capability to access
+ the I/O ports [FROM; TO] directly. MASTER_PORT is the master device port.
+
+ The function returns KERN_INVALID_ARGUMENT if TARGET_TASK is not a task,
+ or FROM is greater than TO. */
+routine i386_io_perm_create(
+ master_port : mach_port_t;
+ from : io_port_t;
+ to : io_port_t;
+ out io_perm : io_perm_t);
+
+/* Modify the I/O permissions for TARGET_TASK. If ENABLE is TRUE, the
+ permission to access the I/O ports specified by IO_PERM is granted,
+ otherwise it is withdrawn.
+
+ The function returns KERN_INVALID_ARGUMENT if TARGET_TASK is not a valid
+ task or IO_PERM not a valid I/O permission port. */
+routine i386_io_perm_modify(
+ target_task : task_t;
+ io_perm : io_perm_t;
+ enable : boolean_t);
/* Modify one of a few available thread-specific segment descriptor slots.
The SELECTOR must be a value from a previous call (on any thread),
diff --git a/i386/include/mach/i386/mach_i386_types.h b/i386/include/mach/i386/mach_i386_types.h
index 43780a3..b03c0b0 100644
--- a/i386/include/mach/i386/mach_i386_types.h
+++ b/i386/include/mach/i386/mach_i386_types.h
@@ -31,11 +31,6 @@
#define _MACH_MACH_I386_TYPES_H_
/*
- * Array of devices.
- */
-typedef device_t *device_list_t;
-
-/*
* i386 segment descriptor.
*/
struct descriptor {
@@ -46,4 +41,15 @@ struct descriptor {
typedef struct descriptor descriptor_t;
typedef struct descriptor *descriptor_list_t;
+/*
+ * i386 I/O port
+ */
+
+#ifdef MACH_KERNEL
+#include <i386/io_perm.h>
+#else
+typedef unsigned short io_port_t;
+typedef mach_port_t io_perm_t;
+#endif
+
#endif /* _MACH_MACH_I386_TYPES_H_ */