aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2023-01-24 01:44:23 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-01-25 02:06:29 +0100
commitb379d5afdf65cce11426ab0349a3778b3fd632f5 (patch)
tree806d1d45fad3b713bd3e967ccf39847db427aa55
parent2281d4ba935f2b6c06d2ee0e5258c41c78bd8d39 (diff)
downloadgnumach-b379d5afdf65cce11426ab0349a3778b3fd632f5.tar.gz
gnumach-b379d5afdf65cce11426ab0349a3778b3fd632f5.tar.bz2
gnumach-b379d5afdf65cce11426ab0349a3778b3fd632f5.zip
Fix several warnings for -Wmissing-prototypes (part 2)
* i386/i386/io_map.c: code is unused. * i386/i386/io_perm.c: include mig prototypes. * i386/i386/mp_desc.c: Deleted interrupt_stack_alloc since it is not used. * i386/i386/seg.h: Moved descriptor structs to i386/include/mach/i386/mach_i386_types.h as that represents the interface types for RPCs. Defined aliases for real_descriptor since those are used by the i386 RPCs. Inlined many functions here too and removed seg.c. * i386/i386/seg.c: Removed. All the functions are inline now. * i386/i386/trap.c: Use static. * i386/i386/trap.h: Define missing prototypes. * i386/i386/tss.h: Use static inline for ltr. * i386/i386/user_ldt.c: Include mig prototypes. * i386/include/mach/i386/mach_i386.defs: Define real_descriptor_t types since those are used in the RPC definition. Now both prototypes and definitions will match. * i386/include/mach/i386/mach_i386_types.h: Move struct descriptor from seg.h since we need those for the RPC interfaces. Removed include of io_perm.h since it generates circular includes otherwise. * i386/intel/pmap.c: pmap_map is unused. Added static qualifier for several functions. * i386/intel/pmap.h: pmap_update_interrupt declared for non-SMP and SMP. Message-Id: <Y89+R2VekOQK4IUo@jupiter.lan>
-rw-r--r--i386/Makefrag.am2
-rw-r--r--i386/i386/io_map.c92
-rw-r--r--i386/i386/io_perm.c2
-rw-r--r--i386/i386/mp_desc.c53
-rw-r--r--i386/i386/seg.c5
-rw-r--r--i386/i386/seg.h42
-rw-r--r--i386/i386/trap.c2
-rw-r--r--i386/i386/trap.h20
-rw-r--r--i386/i386/tss.h2
-rw-r--r--i386/i386/user_ldt.c1
-rw-r--r--i386/include/mach/i386/mach_i386.defs13
-rw-r--r--i386/include/mach/i386/mach_i386_types.h49
-rw-r--r--i386/intel/pmap.c33
-rw-r--r--i386/intel/pmap.h3
-rw-r--r--vm/pmap.h1
-rw-r--r--x86_64/Makefrag.am1
16 files changed, 89 insertions, 232 deletions
diff --git a/i386/Makefrag.am b/i386/Makefrag.am
index c1043c4f..0d9b084d 100644
--- a/i386/Makefrag.am
+++ b/i386/Makefrag.am
@@ -140,7 +140,6 @@ libkernel_a_SOURCES += \
i386/i386/pmap.h \
i386/i386/proc_reg.h \
i386/i386/sched_param.h \
- i386/i386/seg.c \
i386/i386/seg.h \
i386/i386/setjmp.h \
i386/i386/smp.h \
@@ -169,7 +168,6 @@ libkernel_a_SOURCES += \
i386/i386/apic.c \
i386/i386/hardclock.c \
i386/i386/hardclock.h \
- i386/i386/io_map.c \
i386/i386/irq.c \
i386/i386/irq.h \
i386/i386/pit.c \
diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c
deleted file mode 100644
index 368f200b..00000000
--- a/i386/i386/io_map.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#include <kern/printf.h>
-#include <mach/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_map.h>
-
-extern vm_offset_t kernel_virtual_start;
-
-/*
- * Allocate and map memory for devices that may need to be mapped before
- * Mach VM is running.
- */
-static vm_offset_t
-io_map(
- phys_addr_t phys_addr,
- vm_size_t size)
-{
- vm_offset_t start;
-
- if (kernel_map == VM_MAP_NULL) {
- /*
- * VM is not initialized. Grab memory.
- */
- start = kernel_virtual_start;
- kernel_virtual_start += round_page(size);
- printf("stealing kernel virtual addresses %08zx-%08zx\n", start, kernel_virtual_start);
- }
- else {
- (void) kmem_alloc_pageable(kernel_map, &start, round_page(size));
- }
- (void) pmap_map_bd(start, phys_addr, phys_addr + round_page(size),
- VM_PROT_READ|VM_PROT_WRITE);
- return (start);
-}
-
-/*
- * Allocate and map memory for devices that may need to be mapped before
- * Mach VM is running.
- *
- * This maps the all pages containing [PHYS_ADDR:PHYS_ADDR + SIZE].
- * For contiguous requests to those pages will reuse the previously
- * established mapping.
- *
- * Warning: this leaks memory maps for now, do not use it yet for something
- * else than Mach shutdown.
- */
-vm_offset_t
-io_map_cached(
- phys_addr_t phys_addr,
- vm_size_t size)
-{
- static phys_addr_t base;
- static vm_size_t length;
- static vm_offset_t map;
-
- if (! map
- || (phys_addr < base)
- || (base + length < phys_addr + size))
- {
- base = trunc_phys(phys_addr);
- length = round_phys(phys_addr - base + size);
- map = io_map(base, length);
- }
-
- return map + (phys_addr - base);
-}
diff --git a/i386/i386/io_perm.c b/i386/i386/io_perm.c
index 6db60f73..aabff49b 100644
--- a/i386/i386/io_perm.c
+++ b/i386/i386/io_perm.c
@@ -64,6 +64,8 @@
#include <device/device_emul.h>
#include <device/device_port.h>
+#include <i386/i386/mach_i386.server.h>
+
#include "io_perm.h"
#include "gdt.h"
#include "pcb.h"
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 1e9ea0fc..bcf2fbe7 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -167,59 +167,10 @@ mp_desc_init(int mycpu)
}
}
-kern_return_t intel_startCPU(int slot_num)
+static kern_return_t intel_startCPU(int slot_num)
{
printf("TODO: intel_startCPU\n");
-}
-
-/*
- * Called after all CPUs have been found, but before the VM system
- * is running. The machine array must show which CPUs exist.
- */
-void
-interrupt_stack_alloc(void)
-{
- int i;
- int cpu_count;
- vm_offset_t stack_start;
-
- /*
- * Count the number of CPUs.
- */
- cpu_count = 0;
- for (i = 0; i < NCPUS; i++)
- if (machine_slot[i].is_cpu)
- cpu_count++;
-
- /*
- * Allocate an interrupt stack for each CPU except for
- * the master CPU (which uses the bootstrap stack)
- */
- if (!init_alloc_aligned(INTSTACK_SIZE*(cpu_count-1), &stack_start))
- panic("not enough memory for interrupt stacks");
- stack_start = phystokv(stack_start);
-
- /*
- * Set up pointers to the top of the interrupt stack.
- */
- for (i = 0; i < NCPUS; i++) {
- if (i == master_cpu) {
- interrupt_stack[i] = (vm_offset_t) _intstack;
- int_stack_top[i] = (vm_offset_t) _eintstack;
- }
- else if (machine_slot[i].is_cpu) {
- interrupt_stack[i] = stack_start;
- int_stack_top[i] = stack_start + INTSTACK_SIZE;
-
- stack_start += INTSTACK_SIZE;
- }
- }
-
- /*
- * Set up the barrier address. All thread stacks MUST
- * be above this address.
- */
- int_stack_high = stack_start;
+ return KERN_FAILURE;
}
/* XXX should be adjusted per CPU speed */
diff --git a/i386/i386/seg.c b/i386/i386/seg.c
deleted file mode 100644
index d57c255e..00000000
--- a/i386/i386/seg.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#define MACH_INLINE
-#include "seg.h"
-#include "tss.h"
-
diff --git a/i386/i386/seg.h b/i386/i386/seg.h
index 30cfdc86..74853718 100644
--- a/i386/i386/seg.h
+++ b/i386/i386/seg.h
@@ -32,6 +32,7 @@
#define _I386_SEG_H_
#include <mach/inline.h>
+#include <mach/machine/mach_i386_types.h>
/*
* i386 segmentation.
@@ -46,35 +47,6 @@
#ifndef __ASSEMBLER__
-/*
- * Real segment descriptor.
- */
-struct real_descriptor {
- unsigned int limit_low:16, /* limit 0..15 */
- base_low:16, /* base 0..15 */
- base_med:8, /* base 16..23 */
- access:8, /* access byte */
- limit_high:4, /* limit 16..19 */
- granularity:4, /* granularity */
- base_high:8; /* base 24..31 */
-};
-
-#ifdef __x86_64__
-struct real_descriptor64 {
- unsigned int limit_low:16, /* limit 0..15 */
- base_low:16, /* base 0..15 */
- base_med:8, /* base 16..23 */
- access:8, /* access byte */
- limit_high:4, /* limit 16..19 */
- granularity:4, /* granularity */
- base_high:8, /* base 24..31 */
- base_ext:32, /* base 32..63 */
- reserved1:8,
- zero:5,
- reserved2:19;
-};
-#endif
-
struct real_gate {
unsigned int offset_low:16, /* offset 0..15 */
selector:16,
@@ -156,15 +128,15 @@ struct pseudo_descriptor
/* Load the processor's IDT, GDT, or LDT pointers. */
-MACH_INLINE void lgdt(struct pseudo_descriptor *pdesc)
+static inline void lgdt(struct pseudo_descriptor *pdesc)
{
__asm volatile("lgdt %0" : : "m" (*pdesc));
}
-MACH_INLINE void lidt(struct pseudo_descriptor *pdesc)
+static inline void lidt(struct pseudo_descriptor *pdesc)
{
__asm volatile("lidt %0" : : "m" (*pdesc));
}
-MACH_INLINE void lldt(unsigned short ldt_selector)
+static inline void lldt(unsigned short ldt_selector)
{
__asm volatile("lldt %w0" : : "r" (ldt_selector) : "memory");
}
@@ -177,7 +149,7 @@ MACH_INLINE void lldt(unsigned short ldt_selector)
/* Fill a segment descriptor. */
-MACH_INLINE void
+static inline void
fill_descriptor(struct real_descriptor *_desc, unsigned base, unsigned limit,
unsigned char access, unsigned char sizebits)
{
@@ -206,7 +178,7 @@ fill_descriptor(struct real_descriptor *_desc, unsigned base, unsigned limit,
}
#ifdef __x86_64__
-MACH_INLINE void
+static inline void
fill_descriptor64(struct real_descriptor64 *_desc, unsigned long base, unsigned limit,
unsigned char access, unsigned char sizebits)
{
@@ -240,7 +212,7 @@ fill_descriptor64(struct real_descriptor64 *_desc, unsigned long base, unsigned
#endif
/* Fill a gate with particular values. */
-MACH_INLINE void
+static inline void
fill_gate(struct real_gate *gate, unsigned long offset, unsigned short selector,
unsigned char access, unsigned char word_count)
{
diff --git a/i386/i386/trap.c b/i386/i386/trap.c
index 1128145e..1e04ae7d 100644
--- a/i386/i386/trap.c
+++ b/i386/i386/trap.c
@@ -88,7 +88,7 @@ extern boolean_t kttd_enabled;
boolean_t debug_all_traps_with_kttd = TRUE;
#endif /* MACH_TTD */
-void
+static void
user_page_fault_continue(kern_return_t kr)
{
thread_t thread = current_thread();
diff --git a/i386/i386/trap.h b/i386/i386/trap.h
index 46612db5..d9df7afa 100644
--- a/i386/i386/trap.h
+++ b/i386/i386/trap.h
@@ -45,6 +45,26 @@ i386_exception(
extern void
thread_kdb_return(void);
+/*
+ * Trap from kernel mode. Only page-fault errors are recoverable,
+ * and then only in special circumstances. All other errors are
+ * fatal.
+ */
+void kernel_trap(struct i386_saved_state *regs);
+
+/*
+ * Trap from user mode.
+ * Return TRUE if from emulated system call.
+ */
+int user_trap(struct i386_saved_state *regs);
+
+/*
+ * Handle AST traps for i386.
+ * Check for delayed floating-point exception from
+ * AT-bus machines.
+ */
+void i386_astintr(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* _I386_TRAP_H_ */
diff --git a/i386/i386/tss.h b/i386/i386/tss.h
index 31e1f5cb..fd7e7147 100644
--- a/i386/i386/tss.h
+++ b/i386/i386/tss.h
@@ -100,7 +100,7 @@ struct task_tss
/* Load the current task register. */
-MACH_INLINE void
+static inline void
ltr(unsigned short segment)
{
__asm volatile("ltr %0" : : "r" (segment) : "memory");
diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c
index fdff518e..858da681 100644
--- a/i386/i386/user_ldt.c
+++ b/i386/i386/user_ldt.c
@@ -39,6 +39,7 @@
#include <i386/seg.h>
#include <i386/thread.h>
#include <i386/user_ldt.h>
+#include <i386/i386/mach_i386.server.h>
#include <stddef.h>
#include "ldt.h"
#include "vm_param.h"
diff --git a/i386/include/mach/i386/mach_i386.defs b/i386/include/mach/i386/mach_i386.defs
index e110c899..4694522b 100644
--- a/i386/include/mach/i386/mach_i386.defs
+++ b/i386/include/mach/i386/mach_i386.defs
@@ -40,9 +40,12 @@ subsystem
MACH_I386_IMPORTS
#endif
-type descriptor_t = struct[2] of int;
+type descriptor_t = struct[2] of uint32_t;
type descriptor_list_t = array[*] of descriptor_t;
+type real_descriptor_t = descriptor_t;
+type real_descriptor_list_t = array[*] of real_descriptor_t;
+
import <mach/machine/mach_i386_types.h>;
#if KERNEL_SERVER
@@ -66,13 +69,13 @@ skip; /* i386_io_port_list */
routine i386_set_ldt(
target_thread : thread_t;
first_selector : int;
- desc_list : descriptor_list_t, serverCopy);
+ desc_list : real_descriptor_list_t, serverCopy);
routine i386_get_ldt(
target_thread : thread_t;
first_selector : int;
selector_count : int;
- out desc_list : descriptor_list_t);
+ out desc_list : real_descriptor_list_t);
/* 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.
@@ -104,10 +107,10 @@ routine i386_io_perm_modify(
routine i386_set_gdt(
target_thread : thread_t;
inout selector : int;
- desc : descriptor_t);
+ desc : real_descriptor_t);
/* Fetch a segment descriptor set with a prior i386_set_gdt call. */
routine i386_get_gdt(
target_thread : thread_t;
selector : int;
- out desc : descriptor_t);
+ out desc : real_descriptor_t);
diff --git a/i386/include/mach/i386/mach_i386_types.h b/i386/include/mach/i386/mach_i386_types.h
index f003636d..bfa91ca0 100644
--- a/i386/include/mach/i386/mach_i386_types.h
+++ b/i386/include/mach/i386/mach_i386_types.h
@@ -30,27 +30,60 @@
#ifndef _MACH_MACH_I386_TYPES_H_
#define _MACH_MACH_I386_TYPES_H_
+#ifndef __ASSEMBLER__
/*
* i386 segment descriptor.
*/
-struct descriptor {
+struct segment_descriptor {
unsigned int low_word;
unsigned int high_word;
};
-typedef struct descriptor descriptor_t;
-typedef struct descriptor *descriptor_list_t;
-typedef const struct descriptor *const_descriptor_list_t;
+typedef struct segment_descriptor descriptor_t;
+typedef struct segment_descriptor *descriptor_list_t;
+typedef const struct descriptor *const_segment_descriptor_list_t;
+
+/*
+ * Real segment descriptor.
+ */
+struct real_descriptor {
+ unsigned int limit_low:16, /* limit 0..15 */
+ base_low:16, /* base 0..15 */
+ base_med:8, /* base 16..23 */
+ access:8, /* access byte */
+ limit_high:4, /* limit 16..19 */
+ granularity:4, /* granularity */
+ base_high:8; /* base 24..31 */
+};
+typedef struct real_descriptor real_descriptor_t;
+typedef real_descriptor_t *real_descriptor_list_t;
+typedef const real_descriptor_list_t const_real_descriptor_list_t;
+
+#ifdef __x86_64__
+struct real_descriptor64 {
+ unsigned int limit_low:16, /* limit 0..15 */
+ base_low:16, /* base 0..15 */
+ base_med:8, /* base 16..23 */
+ access:8, /* access byte */
+ limit_high:4, /* limit 16..19 */
+ granularity:4, /* granularity */
+ base_high:8, /* base 24..31 */
+ base_ext:32, /* base 32..63 */
+ reserved1:8,
+ zero:5,
+ reserved2:19;
+};
+#endif
+
+#endif /* !__ASSEMBLER__ */
/*
* i386 I/O port
*/
-#ifdef MACH_KERNEL
-#include <i386/io_perm.h>
-#else /* MACH_KERNEL */
+#ifndef MACH_KERNEL
typedef unsigned short io_port_t;
typedef mach_port_t io_perm_t;
-#endif /* MACH_KERNEL */
+#endif /* !MACH_KERNEL */
#endif /* _MACH_MACH_I386_TYPES_H_ */
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index 199f824e..84a4cef5 100644
--- a/i386/intel/pmap.c
+++ b/i386/intel/pmap.c
@@ -502,34 +502,9 @@ void ptep_check(ptep_t ptep)
#endif /* DEBUG_PTE_PAGE */
/*
- * Map memory at initialization. The physical addresses being
- * mapped are not managed and are never unmapped.
- *
- * For now, VM is already on, we only need to map the
- * specified memory.
- */
-vm_offset_t pmap_map(
- vm_offset_t virt,
- phys_addr_t start,
- phys_addr_t end,
- int prot)
-{
- int ps;
-
- ps = PAGE_SIZE;
- while (start < end) {
- pmap_enter(kernel_pmap, virt, start, prot, FALSE);
- virt += ps;
- start += ps;
- }
- return(virt);
-}
-
-/*
* Back-door routine for mapping kernel VM at initialization.
* Useful for mapping memory outside the range of direct mapped
* physical memory (i.e., devices).
- * Otherwise like pmap_map.
*/
vm_offset_t pmap_map_bd(
vm_offset_t virt,
@@ -1108,7 +1083,7 @@ valid_page(phys_addr_t addr)
* Must be called with the pmap system and the pmap unlocked,
* since these must be unlocked to use vm_page_grab.
*/
-vm_offset_t
+static vm_offset_t
pmap_page_table_page_alloc(void)
{
vm_page_t m;
@@ -1198,7 +1173,7 @@ void pmap_map_mfn(void *_addr, unsigned long mfn) {
* The page-table page must have all mappings removed,
* and be removed from its page directory.
*/
-void
+static void
pmap_page_table_page_dealloc(vm_offset_t pa)
{
vm_page_t m;
@@ -2600,7 +2575,7 @@ pmap_pageable(
/*
* Clear specified attribute bits.
*/
-void
+static void
phys_attribute_clear(
phys_addr_t phys,
int bits)
@@ -2684,7 +2659,7 @@ phys_attribute_clear(
/*
* Check specified attribute bits.
*/
-boolean_t
+static boolean_t
phys_attribute_test(
phys_addr_t phys,
int bits)
diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h
index bad640c1..d6bf85fb 100644
--- a/i386/intel/pmap.h
+++ b/i386/intel/pmap.h
@@ -268,11 +268,12 @@ boolean_t cpu_update_needed[NCPUS];
*/
void process_pmap_updates(pmap_t);
-void pmap_update_interrupt(void);
extern pmap_t kernel_pmap;
#endif /* NCPUS > 1 */
+void pmap_update_interrupt(void);
+
/*
* Machine dependent routines that are used only for i386/i486.
*/
diff --git a/vm/pmap.h b/vm/pmap.h
index 2201b444..df11af39 100644
--- a/vm/pmap.h
+++ b/vm/pmap.h
@@ -194,7 +194,6 @@ extern void pmap_pageable(
* Back-door routine for mapping kernel VM at initialization.
* Useful for mapping memory outside the range of direct mapped
* physical memory (i.e., devices).
- * Otherwise like pmap_map.
*/
extern vm_offset_t pmap_map_bd(
vm_offset_t virt,
diff --git a/x86_64/Makefrag.am b/x86_64/Makefrag.am
index f5f152b8..71491c2a 100644
--- a/x86_64/Makefrag.am
+++ b/x86_64/Makefrag.am
@@ -163,7 +163,6 @@ if PLATFORM_at
libkernel_a_SOURCES += \
i386/i386/hardclock.c \
i386/i386/hardclock.h \
- i386/i386/io_map.c \
i386/i386/irq.c \
i386/i386/irq.h \
i386/i386/pic.c \