Skip to content

Commit

Permalink
Merge branch 'amd64-smp' of https://github.com/chyyuu/ucore_plus
Browse files Browse the repository at this point in the history
  • Loading branch information
Junjie Mao committed Mar 29, 2013
2 parents d65fe64 + a808296 commit a90a7fc
Show file tree
Hide file tree
Showing 733 changed files with 239,489 additions and 9,320 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@
*.lai
*.la
*.a

# temp files
*~
*.swp
*.bak
*.new
*.org
51 changes: 51 additions & 0 deletions README.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
README for ucore amd64 in ubuntu 12.04 x86-64

-----------------------------
prerequirement:
------------------
intalll gcc x86-64 and qemu-system-x86_64

------------------
build
------------------
cd ucore
1 set kernel configure
make ARCH=amd64 defconfig // use amd64's default configure
OR
make ARCH=amd64 menuconfig //do nothing or select custom config, just save&exit
2 build kernel
make // build obj/kernel.img
3 build file system
make sfsimg // build obj/sfs.img

NOTICE: no need to build swapimg
------------------
run
------------------
./uCore_run -d obj

OR
qemu-system-x86_64 -m 512 -hda obj/kernel.img -drive file=obj/sfs.img,media=disk,cache=writeback,index=2 -s -serial file:obj/serial.log -monitor stdio

------------------
debug
------------------
* qemu+gdb

qemu and gdb do not properly handle mode-switching between 32- and
64-bit code: once gdb connects in 32-bit mode, it will not switch to
64-bit mode. Thus, debugging 64-bit code requires attaching gdb after
qemu is already executing 64-bit code. Do not use -S, since that will
attach in 16-/32-bit mode.

//In a terminal..
$ uCore_run -d obj

//In a different terminal
$ cp gdbinit.amd64 .gdbinit
$ gdb
...
The target architecture is assumed to be i386:x86-64
0xffffffffc011b5fc in ?? ()
(gdb) continue

1 change: 1 addition & 0 deletions README.arm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: add simple introduction about hwo to build and run ucore for arm
24 changes: 24 additions & 0 deletions README.i386
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
README for ucore i386 in ubuntu 12.04 x86-64

-----------------------------
prerequirement:
------------------
intalll gcc x86-64 and qemu-system-x86_64

------------------
build
------------------
cd ucore
make menuconfig ARCH=x86_84
make
make sfsimg
make swapimg

------------------
run
------------------
./uCore_run -d obj

OR
qemu-system-i386 -m 128 -hda obj//kernel.img -drive file=obj//swap.img,media=disk,cache=writeback -drive file=obj//sfs.img,media=disk,cache=writeback -s -serial file:obj//serial.log -monitor stdio

16 changes: 14 additions & 2 deletions autobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ cd ucore
# Remove previous builds first
rm -rf $BUILD_DIR_I386
rm -rf $BUILD_DIR_ARM
rm -rf $BUILD_DIR_AMD64

# Build uCore for i386
make O=$BUILD_DIR_I386 ARCH=i386 defconfig > /dev/null && \
make O=$BUILD_DIR_I386 kernel > /dev/null && \
UCORE_TEST=xx make O=$BUILD_DIR_I386 sfsimg > /dev/null && \
make O=$BUILD_DIR_I386 swapimg > /dev/null
UCORE_TEST=xx make O=$BUILD_DIR_I386 sfsimg > /dev/null
if [ $? -ne 0 ]; then
echo "build uCore for i386 failed!"
exit 1
fi
echo "build uCore for i386: OK"

# Build uCore for arm on goldfishv7
# Disable DDE at present as it violates the checks after all user-mode processes quit
Expand All @@ -30,5 +31,16 @@ if [ $? -ne 0 ]; then
echo "build uCore for arm failed!"
exit 1
fi
echo "build uCore for arm: OK"

# Build uCore for amd64
make O=$BUILD_DIR_AMD64 ARCH=amd64 defconfig > /dev/null && \
make O=$BUILD_DIR_AMD64 kernel > /dev/null && \
UCORE_TEST=xx make O=$BUILD_DIR_AMD64 sfsimg > /dev/null
if [ $? -ne 0 ]; then
echo "build uCore for amd64 failed!"
exit 1
fi
echo "build uCore for amd64: OK"

popd > /dev/null
1 change: 1 addition & 0 deletions autotest.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
BUILD_DIR_I386=build-i386
BUILD_DIR_ARM=build-arm
BUILD_DIR_AMD64=build-amd64
42 changes: 33 additions & 9 deletions autotest.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
#!/bin/bash

NR_CPUS=`grep processor /proc/cpuinfo | wc -l`

pushd `dirname $0` > /dev/null
source autotest.config
cd ucore

# Run tests on i386 silently
./uCore_test -d $BUILD_DIR_I386 -t 20 -r -s ucore > /dev/null 2>&1
if [ $NR_CPUS -ge 4 ]; then
./uCore_test -d $BUILD_DIR_I386 -t 20 -r -s ucore > /dev/null 2>&1 &
PIDS[0]=$!
./uCore_test -t 45 -w 15 -d $BUILD_DIR_ARM -r -s all > /dev/null 2>&1 &
PIDS[1]=$!
./uCore_test -d $BUILD_DIR_AMD64 -t 20 -r -s ucore > /dev/null 2>&1 &
PIDS[2]=$!

# Run tests on arm silently
./uCore_test -t 45 -w 15 -d $BUILD_DIR_ARM -r -s all > /dev/null 2>&1
for i in {0..2}; do
wait ${PIDS[i]}
done
else
# Resource limited. Run the tests one by one
./uCore_test -d $BUILD_DIR_I386 -t 20 -r -s ucore > /dev/null 2>&1
./uCore_test -t 45 -w 15 -d $BUILD_DIR_ARM -r -s all > /dev/null 2>&1
./uCore_test -d $BUILD_DIR_AMD64 -t 20 -r -s ucore > /dev/null 2>&1
fi

# Dump results to stdout
echo "==================== i386 ===================="
cat $BUILD_DIR_I386/test-result.latest/summary
echo ""
echo "==================== arm ===================="
cat $BUILD_DIR_ARM/test-result.latest/summary
echo "========================= SUMMARY =========================="
printf "%-20s%-10s%-10s%-10s%-10s\n" "" passed failed broken total
tail -n 1 $BUILD_DIR_I386/test-result.latest/summary
tail -n 1 $BUILD_DIR_ARM/test-result.latest/summary
tail -n 1 $BUILD_DIR_AMD64/test-result.latest/summary
echo

echo "=========================== i386 ==========================="
head -n $[ `cat $BUILD_DIR_I386/test-result.latest/summary | wc -l` - 3 ] $BUILD_DIR_I386/test-result.latest/summary
echo
echo "=========================== ARM ============================"
head -n $[ `cat $BUILD_DIR_ARM/test-result.latest/summary | wc -l` - 3 ] $BUILD_DIR_ARM/test-result.latest/summary
echo
echo "========================== amd64 ==========================="
head -n $[ `cat $BUILD_DIR_AMD64/test-result.latest/summary | wc -l` - 3 ] $BUILD_DIR_AMD64/test-result.latest/summary

popd > /dev/null
8 changes: 7 additions & 1 deletion ucore/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ src/user-ucore/bin
src/user-ucore/_initial

# generated manuals
*.man
*.man

#ctags file
tags

#temp files
*~
32 changes: 26 additions & 6 deletions ucore/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
TOPDIR=$(shell pwd)
Q :=@


KTREE = $(TOPDIR)/src/kern-ucore
ifndef O
OBJPATH_ROOT := $(TOPDIR)/obj
Expand All @@ -22,8 +21,6 @@ export KCONFIG_CONFIG=$(CONFIG_SCRIPT)
CONFIG_DIR := $(OBJPATH_ROOT)/config
KCONFIG_AUTOCONFIG=$(CONFIG_DIR)/auto.conf
KCONFIG_AUTOHEADER=$(CONFIG_DIR)/autoconf.h
CONFIG_CONFIG_IN = $(KTREE)/arch/$(ARCH)/Kconfig
CONFIG_DEFCONFIG = $(KTREE)/arch/$(ARCH)/configs/$(BOARD)_defconfig

CONFIG_SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
Expand All @@ -35,9 +32,13 @@ MAKEFLAGS += -rR --no-print-directory

#### CROSS COMPILE HERE ####
ARCH ?= $(patsubst "%",%,$(UCONFIG_ARCH))
ARCH ?= amd64
BOARD ?= default
CROSS_COMPILE ?= $(UCONFIG_CROSS_COMPILE)

CONFIG_CONFIG_IN = $(KTREE)/arch/$(ARCH)/Kconfig
CONFIG_DEFCONFIG = $(KTREE)/arch/$(ARCH)/configs/$(BOARD)_defconfig

export CONFIG_SHELL quiet Q KBUILD_VERBOSE
export ARCH CROSS_COMPILE
export KCONFIG_AUTOHEADER KCONFIG_AUTOCONFIG
Expand Down Expand Up @@ -85,7 +86,7 @@ export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
export HOSTCFLAGS

PHONY+=defconfig menuconfig clean all
PHONY+=defconfig menuconfig clean all tags amd64tags run

all: kernel

Expand Down Expand Up @@ -156,7 +157,7 @@ endif
@$(Q)$(MAKE) -f $(TOPDIR)/src/user-ucore/Makefile -C $(TOPDIR)/src/user-ucore initial_dir
-cp -r $(TOPDIR)/src/user-ucore/_initial/* $(TMPSFS)
@rm -f $@
@dd if=/dev/zero of=$@ bs=1M count=$(UCONFIG_SFS_IMAGE_SIZE)
@dd if=/dev/zero of=$@ bs=1M count=$(UCONFIG_SFS_IMAGE_SIZE) >/dev/null 2>&1
@$(TOOLS_MKSFS) $@ $(TMPSFS)
@rm -rf $(TMPSFS)

Expand All @@ -168,7 +169,7 @@ swapimg: $(SWAPFS_FILE)

$(SWAPFS_FILE): | $(OBJPATH_ROOT)
@echo Making $@
$(Q)dd if=/dev/zero of=$@ bs=1M count=128
$(Q)dd if=/dev/zero of=$@ bs=1M count=128 >/dev/null 2>&1
endif

$(OBJPATH_ROOT):
Expand All @@ -187,11 +188,30 @@ clean:
$(Q)$(MAKE) -C $(KTREE) -f Makefile.build clean
$(Q)$(MAKE) -f $(TOPDIR)/src/libs-user-ucore/Makefile -C $(TOPDIR)/src/libs-user-ucore clean
$(Q)$(MAKE) -f $(TOPDIR)/src/user-ucore/Makefile -C $(TOPDIR)/src/user-ucore clean
$(Q)rm -f tags

indent:
$(Q)find $(TOPDIR)/src -name *.c -or -name *.h | grep -vf $(TOPDIR)/misc/indent-whitelist | xargs $(TOPDIR)/misc/Lindent
$(Q)rm -rf `find $(TOPDIR)/src -name *~`

tags:
@echo TAGS ALL
$(Q)rm -f cscope.files cscope.in.out cscope.out cscope.po.out tags
$(Q)ctags -R .
$(Q)find . -type f -name "*.[chS]" >cscope.files
$(Q)cscope -bq

amd64tags:
$(Q)./buildamd64tags.sh
runamd64: kernel sfsimg
qemu-system-x86_64 -serial mon:stdio -nographic -m 512m -hda obj/kernel.img -drive file=obj/sfs.img,media=disk,cache=writeback,index=2 -s
runamd64smp: kernel sfsimg
qemu-system-x86_64 -serial mon:stdio -nographic -m 1g -hda obj/kernel.img -smp 16 -numa node -numa node -drive file=obj/sfs.img,media=disk,cache=writeback,index=2 -s
kvmamd64: kernel sfsimg
qemu-kvm -serial mon:stdio -nographic -m 512m -hda obj/kernel.img -drive file=obj/sfs.img,media=disk,cache=writeback,index=2 -s
kvmamd64smp: kernel sfsimg
qemu-kvm -serial mon:stdio -nographic -m 1g -hda obj/kernel.img -smp 16 -numa node -numa node -drive file=obj/sfs.img,media=disk,cache=writeback,index=2 -s

FORCE:

PHONY += FORCE
Expand Down
6 changes: 6 additions & 0 deletions ucore/buildamd64tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
find . -type f -name "*.[chS]" >all.cscope.files
cat all.cscope.files |awk -F'/' '$2 != "package" && $3 !="glue-kern" && $4 !="module"{print($0)}'|awk -F'/' '$0 !~ /arch\/nios2\// && $0 !~ /arch\/arm\// && $0 !~ /arch\/mips\// && $0 !~ /arch\/i386\// && $0 !~ /or32\// && $0 !~ /arch\/um\// && $0 !~ /yaff/ && $0 !~ /fatfs/{print($0)}' > cscope.files
rm all.cscope.files
cscope -bq
ctags -L cscope.files
6 changes: 6 additions & 0 deletions ucore/buildi386tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
find . -type f -name "*.[chS]" >all.cscope.files
cat all.cscope.files |awk -F'/' '$2 != "package" && $3 !="glue-kern" && $4 !="module"{print($0)}'|awk -F'/' '$0 !~ /arch\/nios2\// && $0 !~ /arch\/arm\// && $0 !~ /arch\/mips\// && $0 !~ /arch\/amd64\// && $0 !~ /or32\// && $0 !~ /arch\/um\// && $0 !~ /yaff/ && $0 !~ /fatfs/{print($0)}' > cscope.files
rm all.cscope.files
cscope -bq
ctags -L cscope.files
1 change: 1 addition & 0 deletions ucore/doc/amd64-smp/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The documents in this directory for amd64(x86-64) smp (multicore) porting.
Loading

0 comments on commit a90a7fc

Please sign in to comment.