Changeset e16e036a in mainline
- Timestamp:
- 2005-11-07T20:04:30Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c4e8ed9d
- Parents:
- d90ca68
- Files:
-
- 1 added
- 11 deleted
- 17 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rd90ca68 re16e036a 1 # 2 # Copyright (C) 2005 Martin Decky 3 # All rights reserved. 4 # 5 # Redistribution and use in source and binary forms, with or without 6 # modification, are permitted provided that the following conditions 7 # are met: 8 # 9 # - Redistributions of source code must retain the above copyright 10 # notice, this list of conditions and the following disclaimer. 11 # - Redistributions in binary form must reproduce the above copyright 12 # notice, this list of conditions and the following disclaimer in the 13 # documentation and/or other materials provided with the distribution. 14 # - The name of the author may not be used to endorse or promote products 15 # derived from this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # 28 29 ## Kernel release 30 # 31 32 VERSION = 0 33 PATCHLEVEL = 1 34 SUBLEVEL = 0 35 EXTRAVERSION = 36 NAME = Dawn 37 RELEASE = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 38 39 ## Make some default assumptions 40 # 41 42 ifndef ARCH 43 ARCH = ia32 44 endif 45 46 ## Common compiler flags 47 # 48 49 CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -Igeneric/include/ 50 LFLAGS = -M 51 52 ## Setup kernel configuration 53 # 54 1 55 include Makefile.config 2 56 include arch/$(ARCH)/Makefile.inc 3 57 include genarch/Makefile.inc 4 58 5 sources=generic/src/cpu/cpu.c \ 59 ifeq ($(CONFIG_DEBUG),n) 60 DEFS += -DNDEBUG 61 endif 62 ifeq ($(CONFIG_DEBUG_SPINLOCK),y) 63 DEFS += -DDEBUG_SPINLOCK 64 endif 65 66 ## Toolchain configuration 67 # 68 69 ifeq ($(COMPILER),native) 70 CC = gcc 71 AS = as 72 LD = ld 73 OBJCOPY = objcopy 74 OBJDUMP = objdump 75 else 76 CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc 77 AS = $(TOOLCHAIN_DIR)/$(TARGET)-as 78 LD = $(TOOLCHAIN_DIR)/$(TARGET)-ld 79 OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy 80 OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump 81 endif 82 83 ## Generic kernel sources 84 # 85 86 GENERIC_SOURCES = \ 87 generic/src/cpu/cpu.c \ 6 88 generic/src/main/main.c \ 7 89 generic/src/main/kinit.c \ … … 36 118 generic/src/fb/font-8x16.c 37 119 38 # CFLAGS options same for all targets 39 CFLAGS+=-nostdinc -Igeneric/include/ -Werror-implicit-function-declaration -Wmissing-prototypes -Werror 120 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) 121 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) 122 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES))) 40 123 41 ifdef DEBUG_SPINLOCK 42 CFLAGS+=-D$(DEBUG_SPINLOCK) 43 endif 124 .PHONY: all clean config depend 44 125 45 ifdef USERSPACE 46 CFLAGS+=-D$(USERSPACE) 47 endif 48 49 ifdef TEST 50 test_objects:=$(addsuffix .o,$(basename test/$(TEST_DIR)/$(TEST_FILE))) 51 CFLAGS+=-D$(TEST) 52 endif 53 arch_objects:=$(addsuffix .o,$(basename $(arch_sources))) 54 genarch_objects:=$(addsuffix .o,$(basename $(genarch_sources))) 55 objects:=$(addsuffix .o,$(basename $(sources))) 56 57 .PHONY : all config depend build clean dist-clean boot 58 59 all: dist-clean config depend build 126 all: kernel.bin 60 127 61 128 -include Makefile.depend 62 129 130 clean: 131 find generic/src/ arch/$(ARCH)/src/ genarch/src/ -name '*.o' -exec rm \{\} \; 132 -rm -f kernel.bin kernel.map kernel.map.pre kernel.objdump src/debug/real_map.bin Makefile.depend generic/include/arch generic/include/genarch 133 63 134 config: 64 find generic/src/ generic/include/ -name arch -type l -exec rm \{\} \; 65 find generic/src/ generic/include/ -name genarch -type l -exec rm \{\} \; 66 ln -s ../../arch/$(ARCH)/src/ generic/src/arch 67 ln -s ../../arch/$(ARCH)/include/ generic/include/arch 68 ln -s ../../genarch/src/ generic/src/genarch 69 ln -s ../../genarch/include/ generic/include/genarch 135 ln -sfn ../../arch/$(ARCH)/include/ generic/include/arch 136 ln -sfn ../../genarch/include/ generic/include/genarch 70 137 71 depend: 72 $(CC) $(CFLAGS) -M $( arch_sources) $(genarch_sources) $(sources) >Makefile.depend138 depend: config 139 $(CC) $(CFLAGS) -M $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > Makefile.depend 73 140 74 build: kernel.bin boot 141 arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in 142 $(CC) $(CFLAGS) -E -x c $< | grep -v "^\#" > $@ 75 143 76 clean: 77 find generic/src/ arch/$(ARCH)/src/ genarch/src/ test/ -name '*.o' -exec rm \{\} \; 78 -rm *.bin kernel.map kernel.map.pre kernel.objdump generic/src/debug/real_map.bin 79 $(MAKE) -C arch/$(ARCH)/boot/ clean 80 81 dist-clean: 82 find generic/src/ generic/include/ -name arch -type l -exec rm \{\} \; 83 find generic/src/ generic/include/ -name genarch -type l -exec rm \{\} \; 84 -rm Makefile.depend 85 -$(MAKE) clean 86 87 generic/src/debug/real_map.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld 144 generic/src/debug/real_map.bin: depend arch/$(ARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) 88 145 $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile generic/src/debug/empty_map.o 89 $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $( arch_objects) $(genarch_objects) $(objects) $(test_objects) generic/src/debug/empty_map.o -o $@ -Map kernel.map.pre90 $(OBJDUMP) -t $( arch_objects) $(genarch_objects) $(objects) $(test_objects) > kernel.objdump146 $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/empty_map.o -o $@ -Map kernel.map.pre 147 $(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > kernel.objdump 91 148 tools/genmap.py kernel.map.pre kernel.objdump generic/src/debug/real_map.bin 92 149 … … 94 151 $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab $< $@ 95 152 96 97 kernel.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld generic/src/debug/real_map.o 98 $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(genarch_objects) $(objects) $(test_objects) generic/src/debug/real_map.o -o $@ -Map kernel.map 153 kernel.bin: depend arch/$(ARCH)/_link.ld $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/real_map.o 154 $(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) generic/src/debug/real_map.o -o $@ -Map kernel.map 99 155 100 156 %.o: %.S … … 106 162 %.o: %.c 107 163 $(CC) $(CFLAGS) -c $< -o $@ 108 109 KS=`cat kernel.bin | wc -c`110 111 boot:112 $(MAKE) -C arch/$(ARCH)/boot build KERNEL_SIZE=$(KS) -
Makefile.config
rd90ca68 re16e036a 1 #ARCH=ia32 2 #ARCH=mips32 3 #ARCH=ia64 4 #ARCH=ppc32 5 #ARCH=amd64 6 #ARCH=sparc64 1 ## General configuration directives 2 # 3 # CONFIG_SMP (n/y) 4 # Support for symetric multiprocessors 5 # 6 # CONFIG_HT (n/y) 7 # Improved support for hyperthreading 8 # 9 # CONFIG_FPU_LAZY (n/y) 10 # Lazy context switching 11 # 7 12 8 # If this is yes, then the native compiler will be used instead of cross compiler 9 NATIVE_COMPILER=no 13 CONFIG_SMP = y 14 CONFIG_HT = y 15 CONFIG_FPU_LAZY = y 10 16 11 # If this is yes, strong CPU ordering is assumed 12 STRONG_ORDERING=no 17 ## Debugging configuration directives 18 # 19 # CONFIG_DEBUG (n/y) 20 # General debuging and assert checking 21 # 22 # CONFIG_DEBUG_SPINLOCK (n/y) 23 # Deadlock detection support for spinlocks 24 # 13 25 14 # Support for symetric multiprocessors 15 SMP=__SMP__ 16 17 # Improved support for hyperthreading 18 HT=__HT__ 19 20 # General debuging and assert checking disable 21 #NDEBUG=__NDEBUG__ 22 23 # Deadlock detection support for spinlocks. 24 DEBUG_SPINLOCK=DEBUG_SPINLOCK 25 26 # Uncomment if you want to compile in userspace support 27 #USERSPACE=__USERSPACE__ 28 29 # Uncomment if you want to run in the test mode 30 #TEST=__TEST__ 31 32 TEST_FILE=test.c 33 34 # Select what test do you want to run 35 #TEST_DIR=synch/rwlock1/ 36 #TEST_DIR=synch/rwlock2/ 37 #TEST_DIR=synch/rwlock3/ 38 #TEST_DIR=synch/rwlock4/ 39 #TEST_DIR=synch/rwlock5/ 40 #TEST_DIR=synch/semaphore1/ 41 #TEST_DIR=synch/semaphore2/ 42 #TEST_DIR=fpu/fpu1/ 43 #TEST_DIR=fpu/sse1/ 44 #TEST_DIR=fpu/mips1/ 45 #TEST_DIR=print/print1/ 46 #TEST_DIR=thread/thread1/ 47 #TEST_DIR=mm/mapping1/ 26 CONFIG_DEBUG = n 27 CONFIG_DEBUG_SPINLOCK = y -
arch/amd64/src/amd64.c
rd90ca68 re16e036a 43 43 #include <print.h> 44 44 #include <arch/cpuid.h> 45 #include <genarch/ firmware/acpi/acpi.h>45 #include <genarch/acpi/acpi.h> 46 46 #include <panic.h> 47 47 -
arch/ia32/Makefile.inc
rd90ca68 re16e036a 1 ifeq (${NATIVE_COMPILER},yes) 2 CC=gcc 3 AS=as 4 LD=ld 5 OBJCOPY=objcopy 6 OBJDUMP=objdump 1 # 2 # Copyright (C) 2005 Martin Decky 3 # All rights reserved. 4 # 5 # Redistribution and use in source and binary forms, with or without 6 # modification, are permitted provided that the following conditions 7 # are met: 8 # 9 # - Redistributions of source code must retain the above copyright 10 # notice, this list of conditions and the following disclaimer. 11 # - Redistributions in binary form must reproduce the above copyright 12 # notice, this list of conditions and the following disclaimer in the 13 # documentation and/or other materials provided with the distribution. 14 # - The name of the author may not be used to endorse or promote products 15 # derived from this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # 28 29 ## Toolchain configuration 30 # 31 32 BFD_NAME = elf32-i386 33 BFD_ARCH = i386 34 TARGET = i686-pc-linux-gnu 35 TOOLCHAIN_DIR = /usr/local/i686/bin 36 37 ## Accepted CPUs 38 # 39 # Default CPU is Pentium 4 40 # 41 42 ifeq ($CPU,athlon-xp) 43 CFLAGS += -march=athlon-xp -mmmx -msse -m3dnow 44 DEFS += -DFENCES=486 45 CONFIG_SMP = n 46 CONFIG_HT = n 47 elseifeq ($CPU,athlon-mp) 48 CFLAGS += -march=athlon-mp -mmmx -msse -m3dnow 49 DEFS += -DFENCES=486 50 elseifeq ($CPU,pentium3) 51 CFLAGS += -march=pentium3 -mmmx -msse -msse2 52 DEFS += -DFENCES=486 7 53 else 8 IA-32_TARGET=i686-pc-linux-gnu 9 10 IA-32_CC_DIR=/usr/local/i686/bin 11 IA-32_BINUTILS_DIR=/usr/local/i686/bin 12 13 CC=$(IA-32_CC_DIR)/$(IA-32_TARGET)-gcc 14 AS=$(IA-32_BINUTILS_DIR)/$(IA-32_TARGET)-as 15 LD=$(IA-32_BINUTILS_DIR)/$(IA-32_TARGET)-ld 16 OBJCOPY=$(IA-32_BINUTILS_DIR)/$(IA-32_TARGET)-objcopy 17 OBJDUMP=$(IA-32_BINUTILS_DIR)/$(IA-32_TARGET)-objdump 54 CFLAGS += -march=pentium4 -mfpmath=sse -mmmx -msse -msse2 -msse3 55 DEFS += -DFENCES=p4 18 56 endif 19 57 20 BFD_NAME=elf32-i386 21 BFD_ARCH=i386 58 ## Own configuration directives 59 # 22 60 23 DEFS:=-DARCH=$(ARCH) -DFPU_LAZY 61 CONFIG_ACPI = y 24 62 25 ifeq (${STRONG_ORDERING},yes) 26 DEFS+=-D__STRONG_ORDERING__ 63 ## Accepted configuration directives 64 # 65 66 ifeq ($(CONFIG_SMP),y) 67 DEFS += -DSMP 68 endif 69 ifeq ($(CONFIG_HT),y) 70 DEFS += -DHT 71 endif 72 ifeq ($(CONFIG_FPU_LAZY),y) 73 DEFS += -DFPU_LAZY 27 74 endif 28 75 29 ifdef SMP 30 DEFS+=-D$(SMP) 31 endif 32 33 ifdef HT 34 DEFS+=-D$(HT) 35 endif 36 37 CPPFLAGS=$(DEFS) -nostdinc -Iinclude/ 38 CFLAGS=$(CPPFLAGS) -nostdlib -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 39 LFLAGS=-M 40 41 arch/$(ARCH)/_link.ld: arch/$(ARCH)/_link.ld.in 42 $(CC) $(CFLAGS) -E -x c $< | grep -v "^\#" > $@ 43 44 arch_sources= \ 45 generic/src/arch/context.s \ 46 generic/src/arch/debug/panic.s \ 47 generic/src/arch/delay.s \ 48 generic/src/arch/asm.S \ 49 generic/src/arch/proc/scheduler.c \ 50 generic/src/arch/bios/bios.c \ 51 generic/src/arch/smp/ap.S \ 52 generic/src/arch/smp/apic.c \ 53 generic/src/arch/smp/mps.c \ 54 generic/src/arch/smp/smp.c \ 55 generic/src/arch/atomic.S \ 56 generic/src/arch/smp/ipi.c \ 57 generic/src/arch/ia32.c \ 58 generic/src/arch/interrupt.c \ 59 generic/src/arch/pm.c \ 60 generic/src/arch/userspace.c \ 61 generic/src/arch/cpu/cpu.c \ 62 generic/src/arch/mm/frame.c \ 63 generic/src/arch/mm/memory_init.c \ 64 generic/src/arch/mm/page.c \ 65 generic/src/arch/mm/tlb.c \ 66 generic/src/arch/drivers/i8042.c \ 67 generic/src/arch/drivers/i8254.c \ 68 generic/src/arch/drivers/i8259.c \ 69 generic/src/arch/drivers/ega.c \ 70 generic/src/arch/boot/boot.S \ 71 generic/src/arch/boot/memmap.S\ 72 generic/src/arch/fpu_context.c\ 73 generic/src/arch/fmath.c 76 ARCH_SOURCES = \ 77 arch/$(ARCH)/src/context.s \ 78 arch/$(ARCH)/src/debug/panic.s \ 79 arch/$(ARCH)/src/delay.s \ 80 arch/$(ARCH)/src/asm.S \ 81 arch/$(ARCH)/src/proc/scheduler.c \ 82 arch/$(ARCH)/src/bios/bios.c \ 83 arch/$(ARCH)/src/smp/ap.S \ 84 arch/$(ARCH)/src/smp/apic.c \ 85 arch/$(ARCH)/src/smp/mps.c \ 86 arch/$(ARCH)/src/smp/smp.c \ 87 arch/$(ARCH)/src/atomic.S \ 88 arch/$(ARCH)/src/smp/ipi.c \ 89 arch/$(ARCH)/src/ia32.c \ 90 arch/$(ARCH)/src/interrupt.c \ 91 arch/$(ARCH)/src/pm.c \ 92 arch/$(ARCH)/src/userspace.c \ 93 arch/$(ARCH)/src/cpu/cpu.c \ 94 arch/$(ARCH)/src/mm/frame.c \ 95 arch/$(ARCH)/src/mm/memory_init.c \ 96 arch/$(ARCH)/src/mm/page.c \ 97 arch/$(ARCH)/src/mm/tlb.c \ 98 arch/$(ARCH)/src/drivers/i8042.c \ 99 arch/$(ARCH)/src/drivers/i8254.c \ 100 arch/$(ARCH)/src/drivers/i8259.c \ 101 arch/$(ARCH)/src/drivers/ega.c \ 102 arch/$(ARCH)/src/boot/boot.S \ 103 arch/$(ARCH)/src/boot/memmap.S \ 104 arch/$(ARCH)/src/fpu_context.c\ 105 arch/$(ARCH)/src/fmath.c -
arch/ia32/include/ega.h
rd90ca68 re16e036a 38 38 extern void ega_putchar(const char ch); 39 39 40 static void ega_check_cursor(void);41 static void ega_display_char(char ch);42 43 40 #endif -
arch/ia32/src/cpu/cpu.c
rd90ca68 re16e036a 101 101 { 102 102 cpu_info_t info; 103 int i;104 103 105 104 CPU->arch.vendor = VendorUnknown; -
arch/ia32/src/drivers/ega.c
rd90ca68 re16e036a 59 59 } 60 60 61 void ega_display_char(char ch)61 static void ega_display_char(char ch) 62 62 { 63 63 __u8 *vram = (__u8 *) PA2KA(VIDEORAM); … … 69 69 * This function takes care of scrolling. 70 70 */ 71 void ega_check_cursor(void)71 static void ega_check_cursor(void) 72 72 { 73 73 if (ega_cursor < SCREEN) -
arch/ia32/src/ia32.c
rd90ca68 re16e036a 45 45 #include <arch/interrupt.h> 46 46 #include <arch/asm.h> 47 #include <genarch/ firmware/acpi/acpi.h>47 #include <genarch/acpi/acpi.h> 48 48 49 49 #include <arch/bios/bios.h> -
arch/ia32/src/smp/smp.c
rd90ca68 re16e036a 31 31 #include <arch/smp/mps.h> 32 32 #include <arch/smp/ap.h> 33 #include <genarch/ firmware/acpi/acpi.h>34 #include <genarch/ firmware/acpi/madt.h>33 #include <genarch/acpi/acpi.h> 34 #include <genarch/acpi/madt.h> 35 35 #include <config.h> 36 36 #include <synch/waitq.h> -
genarch/Makefile.inc
rd90ca68 re16e036a 1 # Copyright (C) 2005 Martin Decky 2 # All rights reserved. 1 3 # 2 # Open Firmware 4 # Redistribution and use in source and binary forms, with or without 5 # modification, are permitted provided that the following conditions 6 # are met: 3 7 # 4 OFW=no 8 # - Redistributions of source code must retain the above copyright 9 # notice, this list of conditions and the following disclaimer. 10 # - Redistributions in binary form must reproduce the above copyright 11 # notice, this list of conditions and the following disclaimer in the 12 # documentation and/or other materials provided with the distribution. 13 # - The name of the author may not be used to endorse or promote products 14 # derived from this software without specific prior written permission. 15 # 16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # 5 27 6 ifeq ($(ARCH),ppc32) 7 OFW=yes 28 ## Accepted configuration directives 29 # 30 31 ifeq ($(CONFIG_OFW),y) 32 GENARCH_SOURCES += \ 33 genarch/src/firmware/ofw/ofw.c 8 34 endif 9 10 ifeq ($(ARCH),sparc64) 11 OFW=yes 35 ifeq ($(CONFIG_ACPI),y) 36 GENARCH_SOURCES += \ 37 genarch/src/acpi/acpi.c \ 38 genarch/src/acpi/matd.c 12 39 endif 13 14 #15 # Advanced Configuration and Power Interface (ACPI)16 #17 ACPI=no18 19 ifeq ($(ARCH),ia32)20 ACPI=yes21 endif22 23 ifeq ($(ARCH),amd64)24 ACPI=yes25 endif26 27 ifeq ($(ARCH),ia64)28 #ACPI=yes29 endif30 31 32 ifeq ($(OFW),yes)33 genarch_sources+=generic/src/genarch/firmware/ofw/ofw.c34 endif35 36 ifeq ($(ACPI),yes)37 genarch_sources+=generic/src/genarch/firmware/acpi/acpi.c \38 generic/src/genarch/firmware/acpi/madt.c39 endif -
genarch/include/acpi/acpi.h
rd90ca68 re16e036a 81 81 82 82 extern void acpi_init(void); 83 static int rsdp_check(__u8 *rsdp);84 static void map_sdt(struct acpi_sdt_header *sdt);85 83 extern int acpi_sdt_check(__u8 *sdt); 86 static void configure_via_rsdt(void);87 static void configure_via_xsdt(void);88 84 89 85 #endif /* __ACPI_H__ */ -
genarch/include/acpi/madt.h
rd90ca68 re16e036a 30 30 #define __MADT_H__ 31 31 32 #include <genarch/ firmware/acpi/acpi.h>32 #include <genarch/acpi/acpi.h> 33 33 #include <arch/smp/apic.h> 34 34 #include <arch/smp/smp.h> -
genarch/src/acpi/acpi.c
rd90ca68 re16e036a 27 27 */ 28 28 29 #include <genarch/ firmware/acpi/acpi.h>30 #include <genarch/ firmware/acpi/madt.h>29 #include <genarch/acpi/acpi.h> 30 #include <genarch/acpi/madt.h> 31 31 #include <arch/bios/bios.h> 32 32 … … 45 45 }; 46 46 47 int rsdp_check(__u8 *rsdp) {47 static int rsdp_check(__u8 *rsdp) { 48 48 struct acpi_rsdp *r = (struct acpi_rsdp *) rsdp; 49 49 __u8 sum = 0; … … 78 78 } 79 79 80 void map_sdt(struct acpi_sdt_header *sdt)80 static void map_sdt(struct acpi_sdt_header *sdt) 81 81 { 82 82 map_page_to_frame((__address) sdt, (__address) sdt, PAGE_NOT_CACHEABLE, 0); 83 83 map_structure((__address) sdt, sdt->length); 84 } 85 86 static void configure_via_rsdt(void) 87 { 88 int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u32); 89 90 for (i=0; i<cnt; i++) { 91 for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) { 92 struct acpi_sdt_header *h = (struct acpi_sdt_header *) (__native) acpi_rsdt->entry[i]; 93 94 map_sdt(h); 95 if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) { 96 if (!acpi_sdt_check((__u8 *) h)) 97 goto next; 98 *signature_map[j].sdt_ptr = h; 99 printf("%P: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); 100 } 101 } 102 next: 103 ; 104 } 105 } 106 107 static void configure_via_xsdt(void) 108 { 109 int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u64); 110 111 for (i=0; i<cnt; i++) { 112 for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) { 113 struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((__address) acpi_rsdt->entry[i]); 114 115 map_sdt(h); 116 if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) { 117 if (!acpi_sdt_check((__u8 *) h)) 118 goto next; 119 *signature_map[j].sdt_ptr = h; 120 printf("%P: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description); 121 } 122 } 123 next: 124 ; 125 } 126 84 127 } 85 128 … … 131 174 } 132 175 133 void configure_via_rsdt(void)134 {135 int i, j, cnt = (acpi_rsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u32);136 137 for (i=0; i<cnt; i++) {138 for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) {139 struct acpi_sdt_header *h = (struct acpi_sdt_header *) (__native) acpi_rsdt->entry[i];140 141 map_sdt(h);142 if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) {143 if (!acpi_sdt_check((__u8 *) h))144 goto next;145 *signature_map[j].sdt_ptr = h;146 printf("%P: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description);147 }148 }149 next:150 ;151 }152 }153 154 void configure_via_xsdt(void)155 {156 int i, j, cnt = (acpi_xsdt->header.length - sizeof(struct acpi_sdt_header))/sizeof(__u64);157 158 for (i=0; i<cnt; i++) {159 for (j=0; j<sizeof(signature_map)/sizeof(struct acpi_signature_map); j++) {160 struct acpi_sdt_header *h = (struct acpi_sdt_header *) ((__address) acpi_rsdt->entry[i]);161 162 map_sdt(h);163 if (*((__u32 *) &h->signature[0])==*((__u32 *) &signature_map[j].signature[0])) {164 if (!acpi_sdt_check((__u8 *) h))165 goto next;166 *signature_map[j].sdt_ptr = h;167 printf("%P: ACPI %s\n", *signature_map[j].sdt_ptr, signature_map[j].description);168 }169 }170 next:171 ;172 }173 174 } -
genarch/src/acpi/matd.c
rd90ca68 re16e036a 29 29 #include <arch/types.h> 30 30 #include <typedefs.h> 31 #include <genarch/ firmware/acpi/acpi.h>32 #include <genarch/ firmware/acpi/madt.h>31 #include <genarch/acpi/acpi.h> 32 #include <genarch/acpi/madt.h> 33 33 #include <arch/smp/apic.h> 34 34 #include <arch/smp/smp.h> -
generic/include/print.h
rd90ca68 re16e036a 37 37 #define INT64 8 38 38 39 static void print_double(double num, __u8 modifier, __u16 precision) ;40 static void print_str(const char *str);41 static void print_fixed_hex(const __u64 num, const int width);42 static void print_number(const __native num, const unsigned int base);43 44 39 extern void putchar(const char c); 45 40 extern void printf(const char *fmt, ...); -
generic/include/proc/scheduler.h
rd90ca68 re16e036a 45 45 46 46 extern volatile count_t nrdy; 47 48 static thread_t *find_best_thread(void);49 static void relink_rq(int start);50 static void scheduler_separated_stack(void);51 52 47 extern void scheduler_init(void); 53 48 -
generic/include/proc/thread.h
rd90ca68 re16e036a 113 113 extern link_t threads_head; /**< List of all threads in the system. */ 114 114 115 static void cushion(void);116 117 115 extern void thread_init(void); 118 116 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags); -
generic/src/debug/print.c
rd90ca68 re16e036a 42 42 #define DEFAULT_DOUBLE_BUFFER_SIZE 128 43 43 44 void print_double(double num, __u8 modifier, __u16 precision) 44 45 /** Print NULL terminated string 46 * 47 * Print characters from str using putchar() until 48 * \\0 character is reached. 49 * 50 * @param str Characters to print. 51 * 52 */ 53 static void print_str(const char *str) 54 { 55 int i = 0; 56 char c; 57 58 while (c = str[i++]) 59 putchar(c); 60 } 61 62 63 /** Print hexadecimal digits 64 * 65 * Print fixed count of hexadecimal digits from 66 * the number num. The digits are printed in 67 * natural left-to-right order starting with 68 * the width-th digit. 69 * 70 * @param num Number containing digits. 71 * @param width Count of digits to print. 72 * 73 */ 74 static void print_fixed_hex(const __u64 num, const int width) 75 { 76 int i; 77 78 for (i = width*8 - 4; i >= 0; i -= 4) 79 putchar(digits[(num>>i) & 0xf]); 80 } 81 82 83 /** Print number in given base 84 * 85 * Print significant digits of a number in given 86 * base. 87 * 88 * @param num Number to print. 89 * @param base Base to print the number in (should 90 * be in range 2 .. 16). 91 * 92 */ 93 static void print_number(const __native num, const unsigned int base) 94 { 95 int val = num; 96 char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */ 97 int i = sizeof(__native)*8-1; 98 99 do { 100 d[i--] = digits[val % base]; 101 } while (val /= base); 102 103 d[sizeof(__native)*8] = 0; 104 print_str(&d[i + 1]); 105 } 106 107 108 static void print_double(double num, __u8 modifier, __u16 precision) 45 109 { 46 110 double intval,intval2; … … 143 207 } 144 208 145 /** Print NULL terminated string146 *147 * Print characters from str using putchar() until148 * \\0 character is reached.149 *150 * @param str Characters to print.151 *152 */153 void print_str(const char *str)154 {155 int i = 0;156 char c;157 158 while (c = str[i++])159 putchar(c);160 }161 162 163 /** Print hexadecimal digits164 *165 * Print fixed count of hexadecimal digits from166 * the number num. The digits are printed in167 * natural left-to-right order starting with168 * the width-th digit.169 *170 * @param num Number containing digits.171 * @param width Count of digits to print.172 *173 */174 void print_fixed_hex(const __u64 num, const int width)175 {176 int i;177 178 for (i = width*8 - 4; i >= 0; i -= 4)179 putchar(digits[(num>>i) & 0xf]);180 }181 182 183 /** Print number in given base184 *185 * Print significant digits of a number in given186 * base.187 *188 * @param num Number to print.189 * @param base Base to print the number in (should190 * be in range 2 .. 16).191 *192 */193 void print_number(const __native num, const unsigned int base)194 {195 int val = num;196 char d[sizeof(__native)*8+1]; /* this is good enough even for base == 2 */197 int i = sizeof(__native)*8-1;198 199 do {200 d[i--] = digits[val % base];201 } while (val /= base);202 203 d[sizeof(__native)*8] = 0;204 print_str(&d[i + 1]);205 }206 207 209 208 210 /** General formatted text print -
generic/src/main/kinit.c
rd90ca68 re16e036a 123 123 */ 124 124 m = vm_create(NULL); 125 if (!m) panic("vm_create"); 125 if (!m) 126 panic("vm_create"); 126 127 u = task_create(m); 127 if (!u) panic("task_create"); 128 if (!u) 129 panic("task_create"); 128 130 t = thread_create(uinit, NULL, u, THREAD_USER_STACK); 129 if (!t) panic("thread_create"); 131 if (!t) 132 panic("thread_create"); 130 133 131 134 /* … … 133 136 */ 134 137 a = vm_area_create(m, VMA_TEXT, 1, UTEXT_ADDRESS); 135 if (!a) panic("vm_area_create: vm_text"); 138 if (!a) 139 panic("vm_area_create: vm_text"); 136 140 vm_area_map(a, m); 137 141 memcpy((void *) PA2KA(a->mapping[0]), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE); … … 141 145 */ 142 146 a = vm_area_create(m, VMA_STACK, 1, USTACK_ADDRESS); 143 if (!a) panic("vm_area_create: vm_stack"); 147 if (!a) 148 panic("vm_area_create: vm_stack"); 144 149 vm_area_map(a, m); 145 150 -
generic/src/proc/scheduler.c
rd90ca68 re16e036a 117 117 * 118 118 */ 119 st ruct thread *find_best_thread(void)119 static struct thread *find_best_thread(void) 120 120 { 121 121 thread_t *t; … … 223 223 * 224 224 */ 225 void relink_rq(int start)225 static void relink_rq(int start) 226 226 { 227 227 link_t head; … … 255 255 256 256 257 /** Scheduler stack switch wrapper 258 * 259 * Second part of the scheduler() function 260 * using new stack. Handling the actual context 261 * switch to a new thread. 262 * 263 */ 264 static void scheduler_separated_stack(void) 265 { 266 int priority; 267 268 ASSERT(CPU != NULL); 269 270 if (THREAD) { 271 switch (THREAD->state) { 272 case Running: 273 THREAD->state = Ready; 274 spinlock_unlock(&THREAD->lock); 275 thread_ready(THREAD); 276 break; 277 278 case Exiting: 279 frame_free((__address) THREAD->kstack); 280 if (THREAD->ustack) { 281 frame_free((__address) THREAD->ustack); 282 } 283 284 /* 285 * Detach from the containing task. 286 */ 287 spinlock_lock(&TASK->lock); 288 list_remove(&THREAD->th_link); 289 spinlock_unlock(&TASK->lock); 290 291 spinlock_unlock(&THREAD->lock); 292 293 spinlock_lock(&threads_lock); 294 list_remove(&THREAD->threads_link); 295 spinlock_unlock(&threads_lock); 296 297 spinlock_lock(&CPU->lock); 298 if(CPU->fpu_owner==THREAD) CPU->fpu_owner=NULL; 299 spinlock_unlock(&CPU->lock); 300 301 free(THREAD); 302 303 break; 304 305 case Sleeping: 306 /* 307 * Prefer the thread after it's woken up. 308 */ 309 THREAD->priority = -1; 310 311 /* 312 * We need to release wq->lock which we locked in waitq_sleep(). 313 * Address of wq->lock is kept in THREAD->sleep_queue. 314 */ 315 spinlock_unlock(&THREAD->sleep_queue->lock); 316 317 /* 318 * Check for possible requests for out-of-context invocation. 319 */ 320 if (THREAD->call_me) { 321 THREAD->call_me(THREAD->call_me_with); 322 THREAD->call_me = NULL; 323 THREAD->call_me_with = NULL; 324 } 325 326 spinlock_unlock(&THREAD->lock); 327 328 break; 329 330 default: 331 /* 332 * Entering state is unexpected. 333 */ 334 panic("tid%d: unexpected state %s\n", THREAD->tid, thread_states[THREAD->state]); 335 break; 336 } 337 THREAD = NULL; 338 } 339 340 341 THREAD = find_best_thread(); 342 343 spinlock_lock(&THREAD->lock); 344 priority = THREAD->priority; 345 spinlock_unlock(&THREAD->lock); 346 347 relink_rq(priority); 348 349 spinlock_lock(&THREAD->lock); 350 351 /* 352 * If both the old and the new task are the same, lots of work is avoided. 353 */ 354 if (TASK != THREAD->task) { 355 vm_t *m1 = NULL; 356 vm_t *m2; 357 358 if (TASK) { 359 spinlock_lock(&TASK->lock); 360 m1 = TASK->vm; 361 spinlock_unlock(&TASK->lock); 362 } 363 364 spinlock_lock(&THREAD->task->lock); 365 m2 = THREAD->task->vm; 366 spinlock_unlock(&THREAD->task->lock); 367 368 /* 369 * Note that it is possible for two tasks to share one vm mapping. 370 */ 371 if (m1 != m2) { 372 /* 373 * Both tasks and vm mappings are different. 374 * Replace the old one with the new one. 375 */ 376 vm_install(m2); 377 } 378 TASK = THREAD->task; 379 } 380 381 THREAD->state = Running; 382 383 #ifdef SCHEDULER_VERBOSE 384 printf("cpu%d: tid %d (priority=%d,ticks=%d,nrdy=%d)\n", CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, CPU->nrdy); 385 #endif 386 387 /* 388 * Copy the knowledge of CPU, TASK, THREAD and preemption counter to thread's stack. 389 */ 390 the_copy(THE, (the_t *) THREAD->kstack); 391 392 context_restore(&THREAD->saved_context); 393 /* not reached */ 394 } 395 396 257 397 /** The scheduler 258 398 * … … 320 460 321 461 322 /** Scheduler stack switch wrapper 323 * 324 * Second part of the scheduler() function 325 * using new stack. Handling the actual context 326 * switch to a new thread. 327 * 328 */ 329 void scheduler_separated_stack(void) 330 { 331 int priority; 332 333 ASSERT(CPU != NULL); 334 335 if (THREAD) { 336 switch (THREAD->state) { 337 case Running: 338 THREAD->state = Ready; 339 spinlock_unlock(&THREAD->lock); 340 thread_ready(THREAD); 341 break; 342 343 case Exiting: 344 frame_free((__address) THREAD->kstack); 345 if (THREAD->ustack) { 346 frame_free((__address) THREAD->ustack); 347 } 348 349 /* 350 * Detach from the containing task. 351 */ 352 spinlock_lock(&TASK->lock); 353 list_remove(&THREAD->th_link); 354 spinlock_unlock(&TASK->lock); 355 356 spinlock_unlock(&THREAD->lock); 357 358 spinlock_lock(&threads_lock); 359 list_remove(&THREAD->threads_link); 360 spinlock_unlock(&threads_lock); 361 362 spinlock_lock(&CPU->lock); 363 if(CPU->fpu_owner==THREAD) CPU->fpu_owner=NULL; 364 spinlock_unlock(&CPU->lock); 365 366 free(THREAD); 367 368 break; 369 370 case Sleeping: 371 /* 372 * Prefer the thread after it's woken up. 373 */ 374 THREAD->priority = -1; 375 376 /* 377 * We need to release wq->lock which we locked in waitq_sleep(). 378 * Address of wq->lock is kept in THREAD->sleep_queue. 379 */ 380 spinlock_unlock(&THREAD->sleep_queue->lock); 381 382 /* 383 * Check for possible requests for out-of-context invocation. 384 */ 385 if (THREAD->call_me) { 386 THREAD->call_me(THREAD->call_me_with); 387 THREAD->call_me = NULL; 388 THREAD->call_me_with = NULL; 389 } 390 391 spinlock_unlock(&THREAD->lock); 392 393 break; 394 395 default: 396 /* 397 * Entering state is unexpected. 398 */ 399 panic("tid%d: unexpected state %s\n", THREAD->tid, thread_states[THREAD->state]); 400 break; 401 } 402 THREAD = NULL; 403 } 404 405 406 THREAD = find_best_thread(); 407 408 spinlock_lock(&THREAD->lock); 409 priority = THREAD->priority; 410 spinlock_unlock(&THREAD->lock); 411 412 relink_rq(priority); 413 414 spinlock_lock(&THREAD->lock); 415 416 /* 417 * If both the old and the new task are the same, lots of work is avoided. 418 */ 419 if (TASK != THREAD->task) { 420 vm_t *m1 = NULL; 421 vm_t *m2; 422 423 if (TASK) { 424 spinlock_lock(&TASK->lock); 425 m1 = TASK->vm; 426 spinlock_unlock(&TASK->lock); 427 } 428 429 spinlock_lock(&THREAD->task->lock); 430 m2 = THREAD->task->vm; 431 spinlock_unlock(&THREAD->task->lock); 432 433 /* 434 * Note that it is possible for two tasks to share one vm mapping. 435 */ 436 if (m1 != m2) { 437 /* 438 * Both tasks and vm mappings are different. 439 * Replace the old one with the new one. 440 */ 441 vm_install(m2); 442 } 443 TASK = THREAD->task; 444 } 445 446 THREAD->state = Running; 447 448 #ifdef SCHEDULER_VERBOSE 449 printf("cpu%d: tid %d (priority=%d,ticks=%d,nrdy=%d)\n", CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, CPU->nrdy); 450 #endif 451 452 /* 453 * Copy the knowledge of CPU, TASK, THREAD and preemption counter to thread's stack. 454 */ 455 the_copy(THE, (the_t *) THREAD->kstack); 456 457 context_restore(&THREAD->saved_context); 458 /* not reached */ 459 } 462 460 463 461 464 -
generic/src/proc/thread.c
rd90ca68 re16e036a 71 71 * 72 72 */ 73 void cushion(void)73 static void cushion(void) 74 74 { 75 75 void (*f)(void *) = THREAD->thread_code;
Note:
See TracChangeset
for help on using the changeset viewer.