/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
#ifndef _I386_SEG_H_
#define _I386_SEG_H_
+
#include <mach_kdb.h>
+#include <stdint.h>
+#include <architecture/i386/sel.h>
/*
* i386 segmentation.
*/
+static inline uint16_t
+sel_to_selector(sel_t sel)
+{
+ union {
+ sel_t sel;
+ uint16_t selector;
+ } tconv;
+
+ tconv.sel = sel;
+
+ return (tconv.selector);
+}
+
+static inline sel_t
+selector_to_sel(uint16_t selector)
+{
+ union {
+ uint16_t selector;
+ sel_t sel;
+ } tconv;
+
+ tconv.selector = selector;
+
+ return (tconv.sel);
+}
+
+#define LDTSZ 15 /* size of the kernel ldt in entries*/
+
+#if MACH_KDB
+#ifdef MACH_BSD
+#define GDTSZ 14
+#else
+#define GDTSZ 11
+#endif
+#else /* MACH_KDB */
+#ifdef MACH_BSD
+#define GDTSZ 13
+#else
+#define GDTSZ 10
+#endif
+#endif /* MACH_KDB */
+
+/*
+ * Interrupt table is always 256 entries long.
+ */
+#define IDTSZ 256
+
#ifndef __ASSEMBLER__
+
+#include <sys/cdefs.h>
+
/*
* Real segment descriptor.
*/
/* word count, for gate */
unsigned int access:8; /* access */
};
+
+/*
+ * Boot-time data for master (or only) CPU
+ */
+extern struct fake_descriptor idt[IDTSZ];
+extern struct fake_descriptor gdt[GDTSZ];
+extern struct fake_descriptor ldt[LDTSZ];
+extern struct i386_tss ktss;
+
+__BEGIN_DECLS
+
+#if MACH_KDB
+extern char db_stack_store[];
+extern char db_task_stack_store[];
+extern struct i386_tss dbtss;
+extern void db_task_start(void);
+#endif /* MACH_KDB */
+
+__END_DECLS
+
#endif /*__ASSEMBLER__*/
#define SZ_32 0x4 /* 32-bit segment */
/*
* Convert selector to descriptor table index.
*/
-#define sel_idx(sel) ((sel)>>3)
+#define sel_idx(sel) (selector_to_sel(sel).index)
+
+#define NULL_SEG 0
/*
* User descriptors for MACH - 32-bit flat address space
#define USER_RPC 0x0f /* mach rpc call gate */
#define USER_CS 0x17 /* user code segment */
#define USER_DS 0x1f /* user data segment */
-
-#define LDTSZ 4
+#define USER_CTHREAD 0x27 /* user cthread area */
+#define USER_SETTABLE 0x2f /* start of user settable ldt entries */
+#define USLDTSZ 10 /* number of user settable entries */
/*
* Kernel descriptors for MACH - 32-bit flat address space.
#endif
#define USER_FPREGS 0x40 /* user-mode access to saved
floating-point registers */
-#define CPU_DATA 0x48 /* per-cpu data */
+#define CPU_DATA_GS 0x48 /* per-cpu data */
#ifdef MACH_BSD
#define USER_LDT 0x58
#if MACH_KDB
#define DEBUG_TSS 0x50 /* debug TSS (uniprocessor) */
-
-#ifdef MACH_BSD
-#define GDTSZ 14
-#else
-#define GDTSZ 11
#endif
-#else
-
-#ifdef MACH_BSD
-#define GDTSZ 13
-#else
-#define GDTSZ 10
-#endif
-#endif
-
-/*
- * Interrupt table is always 256 entries long.
- */
-#define IDTSZ 256
#endif /* _I386_SEG_H_ */