Commit 227b2020 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://ppc.bkbits.net/for-linus-ppc64

into home.transmeta.com:/home/torvalds/v2.5/linux
parents 8766ee13 ebd27d3a
...@@ -44,6 +44,8 @@ $(boottarget-y): vmlinux ...@@ -44,6 +44,8 @@ $(boottarget-y): vmlinux
archclean: archclean:
$(Q)$(MAKE) -f scripts/Makefile.clean obj=arch/ppc64/boot $(Q)$(MAKE) -f scripts/Makefile.clean obj=arch/ppc64/boot
archmrproper:
prepare: include/asm-ppc64/offsets.h prepare: include/asm-ppc64/offsets.h
arch/ppc64/kernel/asm-offsets.s: include/asm include/linux/version.h \ arch/ppc64/kernel/asm-offsets.s: include/asm include/linux/version.h \
......
...@@ -24,35 +24,45 @@ CROSS32_COMPILE = ...@@ -24,35 +24,45 @@ CROSS32_COMPILE =
#CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux- #CROSS32_COMPILE = /usr/local/ppc/bin/powerpc-linux-
BOOTCC := $(CROSS32_COMPILE)gcc BOOTCC := $(CROSS32_COMPILE)gcc
BOOTCFLAGS := $(HOSTCFLAGS) -Iinclude HOSTCC := gcc
BOOTLD := $(CROSS32_COMPILE)ld BOOTCFLAGS := $(HOSTCFLAGS) -Iinclude -fno-builtin
BOOTAS := $(CROSS32_COMPILE)as BOOTAS := $(CROSS32_COMPILE)as
BOOTAFLAGS := -D__ASSEMBLY__ $(HOSTCFLAGS) BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional
BOOTLD := $(CROSS32_COMPILE)ld
CFLAGS := $(CPPFLAGS) -O -fno-builtin -DSTDC_HEADERS BOOTLFLAGS := -Ttext 0x00400000 -e _start -T $(obj)/zImage.lds
LD_ARGS := -Ttext 0x00400000 -e _start BOOTOBJCOPY := $(CROSS32_COMPILE)objcopy
OBJCOPYFLAGS := -S -O binary OBJCOPYFLAGS := contents,alloc,load,readonly,data
obj-boot := start.o main.o zlib.o imagesize.o no_initrd.o src-boot := crt0.S string.S prom.c main.c zlib.c imagesize.c
OBJS := crt0.o start.o main.o zlib.o imagesize.o image.o src-boot := $(addprefix $(obj)/, $(src-boot))
obj-boot := $(addprefix $(obj)/,$(obj-boot)) obj-boot := $(addsuffix .o, $(basename $(src-boot)))
OBJS := $(addprefix $(obj)/,$(OBJS))
targets += $(obj-boot) $(addprefix $(obj)/,image.c image.o)
quiet_cmd_bootcc = BOOTCC $@ quiet_cmd_bootcc = BOOTCC $@
cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
$(obj-boot): %.o: %.c FORCE
$(call if_changed_dep,bootcc)
quiet_cmd_bootas = BOOTAS $@ quiet_cmd_bootas = BOOTAS $@
cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -traditional \ cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
-c -o $@ $<
$(obj)/crt0.o: %.o: %.S FORCE $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
$(call if_changed_dep,bootcc)
$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
$(call if_changed_dep,bootas) $(call if_changed_dep,bootas)
host-progs := piggyback addnote addSystemMap addRamDisk #-----------------------------------------------------------
HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE) # ELF sections within the zImage bootloader/wrapper
EXTRA_TARGETS += zImage zImage.initrd vmlinux.bin vmlinux.gz \ #-----------------------------------------------------------
required := vmlinux .config System.map
initrd := initrd
obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section)))
src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section)))
gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section)))
host-progs := piggy addnote addSystemMap addRamDisk
EXTRA_TARGETS += zImage zImage.initrd imagesize.c \
$(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
$(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
vmlinux.sm vmlinux.initrd vmlinux.sminitrd \ vmlinux.sm vmlinux.initrd vmlinux.sminitrd \
sysmap.o initrd.o sysmap.o initrd.o
...@@ -69,42 +79,48 @@ $(obj)/vmlinux.initrd: vmlinux $(obj)/addRamDisk $(obj)/ramdisk.image.gz System. ...@@ -69,42 +79,48 @@ $(obj)/vmlinux.initrd: vmlinux $(obj)/addRamDisk $(obj)/ramdisk.image.gz System.
$(obj)/vmlinux.sminitrd: $(obj)/vmlinux.sm $(obj)/addRamDisk $(obj)/ramdisk.image.gz FORCE $(obj)/vmlinux.sminitrd: $(obj)/vmlinux.sm $(obj)/addRamDisk $(obj)/ramdisk.image.gz FORCE
$(call if_changed,ramdisk) $(call if_changed,ramdisk)
$(obj)/sysmap.o: System.map $(obj)/piggyback
$(call if_changed,piggy)
addsection = $(BOOTOBJCOPY) $(1) \
--add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(patsubst %.o,%.gz, $(1)) \
--set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(OBJCOPYFLAGS)
quiet_cmd_addnote = ADDNOTE $@
cmd_addnote = $(BOOTLD) $(BOOTLFLAGS) -o $@ $(obj-boot) && $(obj)/addnote $@
quiet_cmd_piggy = PIGGY $@ quiet_cmd_piggy = PIGGY $@
cmd_piggy = $(obj)/piggyback $(@:.o=) < $< | $(BOOTAS) -o $@ cmd_piggy = $(obj)/piggyback $(@:.o=) < $< | $(BOOTAS) -o $@
$(obj)/image.o: $(obj)/vmlinux.gz $(obj)/piggyback FORCE $(call gz-sec, $(required)): $(obj)/kernel-%.gz: %
$(call if_changed,piggy) $(call if_changed,gzip)
$(obj)/sysmap.o: System.map $(obj)/piggyback FORCE $(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz
$(call if_changed,piggy) cp -f $(obj)/ramdisk.image.gz $@
$(obj)/initrd.o: $(obj)/ramdisk.image.gz $(obj)/piggyback FORCE $(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz
$(call if_changed,piggy) touch $@
quiet_cmd_addnote = ADDNOTE $@ $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c
cmd_addnote = $(BOOTLD) $(LD_ARGS) -T $(obj)/zImage.lds -o $@ $(OBJS) $<\ $(call if_changed_dep,bootcc)
&& $(obj)/addnote $@ $(call addsection, $@)
$(obj)/zImage: $(obj)/no_initrd.o $(OBJS) $(obj)/addnote FORCE $(obj)/zImage: obj-boot += $(call obj-sec, $(required))
$(obj)/zImage: $(call obj-sec, $(required)) $(obj-boot) $(obj)/addnote FORCE
$(call if_changed,addnote) $(call if_changed,addnote)
$(obj)/zImage.initrd: $(obj)/initrd.o $(OBJS) $(obj)/addnote FORCE $(obj)/zImage.initrd: obj-boot += $(call obj-sec, $(required) $(initrd))
$(obj)/zImage.initrd: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(obj)/addnote FORCE
$(call if_changed,addnote) $(call if_changed,addnote)
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
$(call if_changed,gzip)
$(obj)/imagesize.c: vmlinux $(obj)/imagesize.c: vmlinux
@echo Generating $@ @echo Generating $@
ls -l vmlinux | \ ls -l vmlinux | \
awk '{printf "/* generated -- do not edit! */\n" \ awk '{printf "/* generated -- do not edit! */\n" \
"int uncompressed_size = %d;\n", $$5}' > $(obj)/imagesize.c "unsigned long vmlinux_filesize = %d;\n", $$5}' > $(obj)/imagesize.c
$(CROSS_COMPILE)nm -n vmlinux | tail -1 | \ $(CROSS_COMPILE)nm -n vmlinux | tail -1 | \
awk '{printf "long vmlinux_end = 0x%s;\n", substr($$1,8)}' \ awk '{printf "unsigned long vmlinux_memsize = 0x%s;\n", substr($$1,8)}' \
>> $(obj)/imagesize.c >> $(obj)/imagesize.c
clean-files := $(targets)
clean-files := $(patsubst $(obj)/%,%, $(obj-boot))
To extract the kernel vmlinux, System.map, .config or initrd from the zImage binary:
objcopy -j .kernel:vmlinux -O binary zImage vmlinux.gz
objcopy -j .kernel:System.map -O binary zImage System.map.gz
objcopy -j .kernel:.config -O binary zImage config.gz
objcopy -j .kernel:initrd -O binary zImage.initrd initrd.gz
Peter
...@@ -25,7 +25,7 @@ void put4k(FILE *file, char *buf ) ...@@ -25,7 +25,7 @@ void put4k(FILE *file, char *buf )
void death(const char *msg, FILE *fdesc, const char *fname) void death(const char *msg, FILE *fdesc, const char *fname)
{ {
printf(msg); fprintf(stderr, msg);
fclose(fdesc); fclose(fdesc);
unlink(fname); unlink(fname);
exit(1); exit(1);
...@@ -66,47 +66,47 @@ int main(int argc, char **argv) ...@@ -66,47 +66,47 @@ int main(int argc, char **argv)
if (argc < 2) { if (argc < 2) {
printf("Name of RAM disk file missing.\n"); fprintf(stderr, "Name of RAM disk file missing.\n");
exit(1); exit(1);
} }
if (argc < 3) { if (argc < 3) {
printf("Name of System Map input file is missing.\n"); fprintf(stderr, "Name of System Map input file is missing.\n");
exit(1); exit(1);
} }
if (argc < 4) { if (argc < 4) {
printf("Name of vmlinux file missing.\n"); fprintf(stderr, "Name of vmlinux file missing.\n");
exit(1); exit(1);
} }
if (argc < 5) { if (argc < 5) {
printf("Name of vmlinux output file missing.\n"); fprintf(stderr, "Name of vmlinux output file missing.\n");
exit(1); exit(1);
} }
ramDisk = fopen(argv[1], "r"); ramDisk = fopen(argv[1], "r");
if ( ! ramDisk ) { if ( ! ramDisk ) {
printf("RAM disk file \"%s\" failed to open.\n", argv[1]); fprintf(stderr, "RAM disk file \"%s\" failed to open.\n", argv[1]);
exit(1); exit(1);
} }
sysmap = fopen(argv[2], "r"); sysmap = fopen(argv[2], "r");
if ( ! sysmap ) { if ( ! sysmap ) {
printf("System Map file \"%s\" failed to open.\n", argv[2]); fprintf(stderr, "System Map file \"%s\" failed to open.\n", argv[2]);
exit(1); exit(1);
} }
inputVmlinux = fopen(argv[3], "r"); inputVmlinux = fopen(argv[3], "r");
if ( ! inputVmlinux ) { if ( ! inputVmlinux ) {
printf("vmlinux file \"%s\" failed to open.\n", argv[3]); fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", argv[3]);
exit(1); exit(1);
} }
outputVmlinux = fopen(argv[4], "w+"); outputVmlinux = fopen(argv[4], "w+");
if ( ! outputVmlinux ) { if ( ! outputVmlinux ) {
printf("output vmlinux file \"%s\" failed to open.\n", argv[4]); fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", argv[4]);
exit(1); exit(1);
} }
...@@ -118,7 +118,7 @@ int main(int argc, char **argv) ...@@ -118,7 +118,7 @@ int main(int argc, char **argv)
fseek(inputVmlinux, 0, SEEK_SET); fseek(inputVmlinux, 0, SEEK_SET);
printf("kernel file size = %d\n", kernelLen); printf("kernel file size = %d\n", kernelLen);
if ( kernelLen == 0 ) { if ( kernelLen == 0 ) {
printf("You must have a linux kernel specified as argv[3]\n"); fprintf(stderr, "You must have a linux kernel specified as argv[3]\n");
exit(1); exit(1);
} }
...@@ -154,15 +154,14 @@ int main(int argc, char **argv) ...@@ -154,15 +154,14 @@ int main(int argc, char **argv)
/* Process the Sysmap file to determine where _end is */ /* Process the Sysmap file to determine where _end is */
sysmapPages = sysmapLen / 4096; sysmapPages = sysmapLen / 4096;
for (i=0; i<sysmapPages; ++i) { /* read the whole file line by line, expect that it doesnt fail */
get4k(sysmap, inbuf); while ( fgets(inbuf, 4096, sysmap) ) ;
}
/* search for _end in the last page of the system map */ /* search for _end in the last page of the system map */
ptr_end = strstr(inbuf, " _end"); ptr_end = strstr(inbuf, " _end");
if (!ptr_end) { if (!ptr_end) {
printf("Unable to find _end in the sysmap file \n"); fprintf(stderr, "Unable to find _end in the sysmap file \n");
printf("inbuf: \n"); fprintf(stderr, "inbuf: \n");
printf("%s \n", inbuf); fprintf(stderr, "%s \n", inbuf);
exit(1); exit(1);
} }
printf("Found _end in the last page of the sysmap - backing up 10 characters it looks like %s", ptr_end-10); printf("Found _end in the last page of the sysmap - backing up 10 characters it looks like %s", ptr_end-10);
......
...@@ -64,38 +64,38 @@ int main(int argc, char **argv) ...@@ -64,38 +64,38 @@ int main(int argc, char **argv)
long padPages = 0; long padPages = 0;
if ( argc < 2 ) if ( argc < 2 )
{ {
printf("Name of System Map file missing.\n"); fprintf(stderr, "Name of System Map file missing.\n");
exit(1); exit(1);
} }
if ( argc < 3 ) if ( argc < 3 )
{ {
printf("Name of vmlinux file missing.\n"); fprintf(stderr, "Name of vmlinux file missing.\n");
exit(1); exit(1);
} }
if ( argc < 4 ) if ( argc < 4 )
{ {
printf("Name of vmlinux output file missing.\n"); fprintf(stderr, "Name of vmlinux output file missing.\n");
exit(1); exit(1);
} }
sysmap = fopen(argv[1], "r"); sysmap = fopen(argv[1], "r");
if ( ! sysmap ) if ( ! sysmap )
{ {
printf("System Map file \"%s\" failed to open.\n", argv[1]); fprintf(stderr, "System Map file \"%s\" failed to open.\n", argv[1]);
exit(1); exit(1);
} }
inputVmlinux = fopen(argv[2], "r"); inputVmlinux = fopen(argv[2], "r");
if ( ! inputVmlinux ) if ( ! inputVmlinux )
{ {
printf("vmlinux file \"%s\" failed to open.\n", argv[2]); fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", argv[2]);
exit(1); exit(1);
} }
outputVmlinux = fopen(argv[3], "w"); outputVmlinux = fopen(argv[3], "w");
if ( ! outputVmlinux ) if ( ! outputVmlinux )
{ {
printf("output vmlinux file \"%s\" failed to open.\n", argv[3]); fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", argv[3]);
exit(1); exit(1);
} }
...@@ -107,7 +107,7 @@ int main(int argc, char **argv) ...@@ -107,7 +107,7 @@ int main(int argc, char **argv)
printf("kernel file size = %ld\n", kernelLen); printf("kernel file size = %ld\n", kernelLen);
if ( kernelLen == 0 ) if ( kernelLen == 0 )
{ {
printf("You must have a linux kernel specified as argv[2]\n"); fprintf(stderr, "You must have a linux kernel specified as argv[2]\n");
exit(1); exit(1);
} }
...@@ -146,17 +146,15 @@ int main(int argc, char **argv) ...@@ -146,17 +146,15 @@ int main(int argc, char **argv)
/* Process the Sysmap file to determine the true end of the kernel */ /* Process the Sysmap file to determine the true end of the kernel */
sysmapPages = sysmapLen / 4096; sysmapPages = sysmapLen / 4096;
printf("System map pages to copy = %ld\n", sysmapPages); printf("System map pages to copy = %ld\n", sysmapPages);
for (i=0; i<sysmapPages; ++i) /* read the whole file line by line, expect that it doesnt fail */
{ while ( fgets(inbuf, 4096, sysmap) ) ;
get4k(sysmap, inbuf);
}
/* search for _end in the last page of the system map */ /* search for _end in the last page of the system map */
ptr_end = strstr(inbuf, " _end"); ptr_end = strstr(inbuf, " _end");
if (!ptr_end) if (!ptr_end)
{ {
printf("Unable to find _end in the sysmap file \n"); fprintf(stderr, "Unable to find _end in the sysmap file \n");
printf("inbuf: \n"); fprintf(stderr, "inbuf: \n");
printf("%s \n", inbuf); fprintf(stderr, "%s \n", inbuf);
exit(1); exit(1);
} }
printf("Found _end in the last page of the sysmap - backing up 10 characters it looks like %s", ptr_end-10); printf("Found _end in the last page of the sysmap - backing up 10 characters it looks like %s", ptr_end-10);
......
...@@ -8,258 +8,41 @@ ...@@ -8,258 +8,41 @@
* *
* NOTE: this code runs in 32 bit mode and is packaged as ELF32. * NOTE: this code runs in 32 bit mode and is packaged as ELF32.
*/ */
#include <asm/ppc_asm.h>
.text .text
.globl _start .globl _start
_start: _start:
lis 9,_start@h lis r9,_start@h
lis 8,_etext@ha lis r8,_etext@ha
addi 8,8,_etext@l addi r8,r8,_etext@l
1: dcbf 0,9 1: dcbf r0,r9
icbi 0,9 icbi r0,r9
addi 9,9,0x20 addi r9,r9,0x20
cmplwi 0,9,8 cmplwi 0,r9,8
blt 1b blt 1b
sync sync
isync isync
## Clear out the BSS as per ANSI C requirements ## Clear out the BSS as per ANSI C requirements
lis 7,_end@ha lis r7,_end@ha
addi 7,7,_end@l # r7 = &_end addi r7,r7,_end@l # r7 = &_end
lis 8,__bss_start@ha # lis r8,__bss_start@ha #
addi 8,8,__bss_start@l # r8 = &_bss_start addi r8,r8,__bss_start@l # r8 = &_bss_start
## Determine how large an area, in number of words, to clear ## Determine how large an area, in number of words, to clear
subf 7,8,7 # r7 = &_end - &_bss_start + 1 subf r7,r8,r7 # r7 = &_end - &_bss_start + 1
addi 7,7,3 # r7 += 3 addi r7,r7,3 # r7 += 3
srwi. 7,7,2 # r7 = size in words. srwi. r7,r7,2 # r7 = size in words.
beq 3f # If the size is zero, do not bother beq 3f # If the size is zero, don't bother
addi 8,8,-4 # r8 -= 4 addi r8,r8,-4 # r8 -= 4
mtctr 7 # SPRN_CTR = number of words to clear mtctr r7 # SPRN_CTR = number of words to clear
li 0,0 # r0 = 0 li r0,0 # r0 = 0
2: stwu 0,4(8) # Clear out a word 2: stwu r0,4(r8) # Clear out a word
bdnz 2b # If we are not done yet, keep clearing bdnz 2b # Keep clearing until done
3: 3:
b start b start
/*
* Flush the dcache and invalidate the icache for a range of addresses.
*
* flush_cache(addr, len)
*/
.global flush_cache
flush_cache:
addi 4,4,0x1f /* len = (len + 0x1f) / 0x20 */
rlwinm. 4,4,27,5,31
mtctr 4
beqlr
1: dcbf 0,3
icbi 0,3
addi 3,3,0x20
bdnz 1b
sync
isync
blr
#define r0 0
#define r3 3
#define r4 4
#define r5 5
#define r6 6
#define r7 7
#define r8 8
.globl strcpy
strcpy:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r5)
bne 1b
blr
.globl strncpy
strncpy:
cmpwi 0,r5,0
beqlr
mtctr r5
addi r6,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r6)
bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
blr
.globl strcat
strcat:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r5)
cmpwi 0,r0,0
bne 1b
addi r5,r5,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r5)
bne 1b
blr
.globl strcmp
strcmp:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r3,1(r5)
cmpwi 1,r3,0
lbzu r0,1(r4)
subf. r3,r0,r3
beqlr 1
beq 1b
blr
.globl strlen
strlen:
addi r4,r3,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
bne 1b
subf r3,r3,r4
blr
.globl memset
memset:
rlwimi r4,r4,8,16,23
rlwimi r4,r4,16,0,15
addi r6,r3,-4
cmplwi 0,r5,4
blt 7f
stwu r4,4(r6)
beqlr
andi. r0,r6,3
add r5,r0,r5
subf r6,r0,r6
rlwinm r0,r5,32-2,2,31
mtctr r0
bdz 6f
1: stwu r4,4(r6)
bdnz 1b
6: andi. r5,r5,3
7: cmpwi 0,r5,0
beqlr
mtctr r5
addi r6,r6,3
8: stbu r4,1(r6)
bdnz 8b
blr
.globl bcopy
bcopy:
mr r6,r3
mr r3,r4
mr r4,r6
b memcpy
.globl memmove
memmove:
cmplw 0,r3,r4
bgt backwards_memcpy
/* fall through */
.globl memcpy
memcpy:
rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
addi r6,r3,-4
addi r4,r4,-4
beq 2f /* if less than 8 bytes to do */
andi. r0,r6,3 /* get dest word aligned */
mtctr r7
bne 5f
1: lwz r7,4(r4)
lwzu r8,8(r4)
stw r7,4(r6)
stwu r8,8(r6)
bdnz 1b
andi. r5,r5,7
2: cmplwi 0,r5,4
blt 3f
lwzu r0,4(r4)
addi r5,r5,-4
stwu r0,4(r6)
3: cmpwi 0,r5,0
beqlr
mtctr r5
addi r4,r4,3
addi r6,r6,3
4: lbzu r0,1(r4)
stbu r0,1(r6)
bdnz 4b
blr
5: subfic r0,r0,4
mtctr r0
6: lbz r7,4(r4)
addi r4,r4,1
stb r7,4(r6)
addi r6,r6,1
bdnz 6b
subf r5,r0,r5
rlwinm. r7,r5,32-3,3,31
beq 2b
mtctr r7
b 1b
.globl backwards_memcpy
backwards_memcpy:
rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
add r6,r3,r5
add r4,r4,r5
beq 2f
andi. r0,r6,3
mtctr r7
bne 5f
1: lwz r7,-4(r4)
lwzu r8,-8(r4)
stw r7,-4(r6)
stwu r8,-8(r6)
bdnz 1b
andi. r5,r5,7
2: cmplwi 0,r5,4
blt 3f
lwzu r0,-4(r4)
subi r5,r5,4
stwu r0,-4(r6)
3: cmpwi 0,r5,0
beqlr
mtctr r5
4: lbzu r0,-1(r4)
stbu r0,-1(r6)
bdnz 4b
blr
5: mtctr r0
6: lbzu r7,-1(r4)
stbu r7,-1(r6)
bdnz 6b
subf r5,r0,r5
rlwinm. r7,r5,32-3,3,31
beq 2b
mtctr r7
b 1b
.globl memcmp
memcmp:
cmpwi 0,r5,0
blelr
mtctr r5
addi r6,r3,-1
addi r4,r4,-1
1: lbzu r3,1(r6)
lbzu r0,1(r4)
subf. r3,r0,r3
bdnzt 2,1b
blr
/* /*
* Copyright (C) Paul Mackerras 1997. * Copyright (C) Paul Mackerras 1997.
* *
* Updates for PPC64 by Todd Inglett & Dave Engebretsen. * Updates for PPC64 by Todd Inglett, Dave Engebretsen & Peter Bergner.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -9,31 +9,31 @@ ...@@ -9,31 +9,31 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#define __KERNEL__ #define __KERNEL__
#include "ppc32-types.h"
#include "zlib.h" #include "zlib.h"
#include <linux/elf.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/bootinfo.h> #include <asm/bootinfo.h>
#undef DEBUG
void memmove(void *dst, void *im, int len); void memmove(void *dst, void *im, int len);
extern void *finddevice(const char *); extern void *finddevice(const char *);
extern int getprop(void *, const char *, void *, int); extern int getprop(void *, const char *, void *, int);
extern void printk(char *fmt, ...);
extern void printf(const char *fmt, ...); extern void printf(const char *fmt, ...);
extern int sprintf(char *buf, const char *fmt, ...); extern int sprintf(char *buf, const char *fmt, ...);
void gunzip(void *, int, unsigned char *, int *); void gunzip(void *, int, unsigned char *, int *);
void *claim(unsigned int, unsigned int, unsigned int); void *claim(unsigned int, unsigned int, unsigned int);
void flush_cache(void *, int); void flush_cache(void *, unsigned long);
void pause(void); void pause(void);
extern void exit(void);
static struct bi_record *make_bi_recs(unsigned long); static struct bi_record *make_bi_recs(unsigned long);
#define RAM_START 0x00000000 #define RAM_START 0x00000000
#define RAM_END (64<<20) #define RAM_END (64<<20)
#define BOOT_START ((unsigned long)_start)
#define BOOT_END ((unsigned long)_end)
/* Value picked to match that used by yaboot */ /* Value picked to match that used by yaboot */
#define PROG_START 0x01400000 #define PROG_START 0x01400000
...@@ -42,18 +42,26 @@ char *begin_avail, *end_avail; ...@@ -42,18 +42,26 @@ char *begin_avail, *end_avail;
char *avail_high; char *avail_high;
unsigned int heap_use; unsigned int heap_use;
unsigned int heap_max; unsigned int heap_max;
unsigned long initrd_start = 0;
unsigned long initrd_size = 0;
extern char _end[]; extern char _end[];
extern char image_data[]; extern char _vmlinux_start[];
extern int image_len; extern char _vmlinux_end[];
extern char initrd_data[]; extern char _sysmap_start[];
extern int initrd_len; extern char _sysmap_end[];
extern char sysmap_data[]; extern char _initrd_start[];
extern int sysmap_len; extern char _initrd_end[];
extern int uncompressed_size; extern unsigned long vmlinux_filesize;
extern long vmlinux_end; extern unsigned long vmlinux_memsize;
struct addr_range {
unsigned long addr;
unsigned long size;
unsigned long memsize;
};
struct addr_range vmlinux = {0, 0, 0};
struct addr_range vmlinuz = {0, 0, 0};
struct addr_range sysmap = {0, 0, 0};
struct addr_range initrd = {0, 0, 0};
static char scratch[128<<10]; /* 128kB of scratch space for gunzip */ static char scratch[128<<10]; /* 128kB of scratch space for gunzip */
...@@ -62,66 +70,130 @@ typedef void (*kernel_entry_t)( unsigned long, ...@@ -62,66 +70,130 @@ typedef void (*kernel_entry_t)( unsigned long,
void *, void *,
struct bi_record *); struct bi_record *);
int (*prom)(void *);
void *chosen_handle;
void *stdin;
void *stdout;
void *stderr;
void void
chrpboot(unsigned long a1, unsigned long a2, void *prom) start(unsigned long a1, unsigned long a2, void *promptr)
{ {
unsigned len; unsigned long i, claim_addr, claim_size;
void *dst = (void *)-1;
unsigned long claim_addr;
unsigned char *im;
extern char _start; extern char _start;
struct bi_record *bi_recs; struct bi_record *bi_recs;
kernel_entry_t kernel_entry; kernel_entry_t kernel_entry;
Elf64_Ehdr *elf64;
printf("chrpboot starting: loaded at 0x%x\n\r", (unsigned)&_start); Elf64_Phdr *elf64ph;
if (initrd_len) { prom = (int (*)(void *)) promptr;
initrd_size = initrd_len; chosen_handle = finddevice("/chosen");
initrd_start = (RAM_END - initrd_size) & ~0xFFF; if (chosen_handle == (void *) -1)
exit();
if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
exit();
stderr = stdout;
if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
exit();
printf("zImage starting: loaded at 0x%x\n\r", (unsigned)&_start);
#if 0
sysmap.size = (unsigned long)(_sysmap_end - _sysmap_start);
sysmap.memsize = sysmap.size;
if ( sysmap.size > 0 ) {
sysmap.addr = (RAM_END - sysmap.size) & ~0xFFF;
claim(sysmap.addr, RAM_END - sysmap.addr, 0);
printf("initial ramdisk moving 0x%lx <- 0x%lx (%lx bytes)\n\r",
sysmap.addr, (unsigned long)_sysmap_start, sysmap.size);
memcpy((void *)sysmap.addr, (void *)_sysmap_start, sysmap.size);
}
#endif
initrd.size = (unsigned long)(_initrd_end - _initrd_start);
initrd.memsize = initrd.size;
if ( initrd.size > 0 ) {
initrd.addr = (RAM_END - initrd.size) & ~0xFFF;
a1 = a2 = 0; a1 = a2 = 0;
claim(initrd_start, RAM_END - initrd_start, 0); claim(initrd.addr, RAM_END - initrd.addr, 0);
printf("initial ramdisk moving 0x%lx <- 0x%lx (%lx bytes)\n\r", printf("initial ramdisk moving 0x%lx <- 0x%lx (%lx bytes)\n\r",
initrd_start, (unsigned long)initrd_data, initrd_size); initrd.addr, (unsigned long)_initrd_start, initrd.size);
memcpy((void *)initrd_start, (void *)initrd_data, initrd_size); memcpy((void *)initrd.addr, (void *)_initrd_start, initrd.size);
} }
im = image_data; vmlinuz.addr = (unsigned long)_vmlinux_start;
len = image_len; vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start);
uncompressed_size = PAGE_ALIGN(uncompressed_size); vmlinux.addr = (unsigned long)(void *)-1;
vmlinux.size = PAGE_ALIGN(vmlinux_filesize);
vmlinux.memsize = vmlinux_memsize;
claim_size = vmlinux.memsize /* PPPBBB: + fudge for bi_recs */;
for(claim_addr = PROG_START; for(claim_addr = PROG_START;
claim_addr <= PROG_START * 8; claim_addr <= PROG_START * 8;
claim_addr += 0x100000) { claim_addr += 0x100000) {
#ifdef DEBUG #ifdef DEBUG
printf(" trying: 0x%08lx\n\r", claim_addr); printf(" trying: 0x%08lx\n\r", claim_addr);
#endif #endif
dst = claim(claim_addr, uncompressed_size, 0); vmlinux.addr = (unsigned long)claim(claim_addr, claim_size, 0);
if (dst != (void *)-1) break; if ((void *)vmlinux.addr != (void *)-1) break;
} }
if (dst == (void *)-1) { if ((void *)vmlinux.addr == (void *)-1) {
printf("claim error, can't allocate kernel memory\n\r"); printf("claim error, can't allocate kernel memory\n\r");
return; exit();
} }
if (im[0] == 0x1f && im[1] == 0x8b) { /* PPPBBB: should kernel always be gziped? */
if (*(unsigned short *)vmlinuz.addr == 0x1f8b) {
avail_ram = scratch; avail_ram = scratch;
begin_avail = avail_high = avail_ram; begin_avail = avail_high = avail_ram;
end_avail = scratch + sizeof(scratch); end_avail = scratch + sizeof(scratch);
printf("gunzipping (0x%x <- 0x%x:0x%0x)...", printf("gunzipping (0x%lx <- 0x%lx:0x%0lx)...",
(unsigned)dst, (unsigned)im, (unsigned)im+len); vmlinux.addr, vmlinuz.addr, vmlinuz.addr+vmlinuz.size);
gunzip(dst, uncompressed_size, im, &len); gunzip((void *)vmlinux.addr, vmlinux.size,
printf("done %u bytes\n\r", len); (unsigned char *)vmlinuz.addr, (int *)&vmlinuz.size);
printf("done %lu bytes\n\r", vmlinuz.size);
printf("%u bytes of heap consumed, max in use %u\n\r", printf("%u bytes of heap consumed, max in use %u\n\r",
(unsigned)(avail_high - begin_avail), heap_max); (unsigned)(avail_high - begin_avail), heap_max);
} else { } else {
memmove(dst, im, len); memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,vmlinuz.size);
}
/* Skip over the ELF header */
elf64 = (Elf64_Ehdr *)vmlinux.addr;
if ( elf64->e_ident[EI_MAG0] != ELFMAG0 ||
elf64->e_ident[EI_MAG1] != ELFMAG1 ||
elf64->e_ident[EI_MAG2] != ELFMAG2 ||
elf64->e_ident[EI_MAG3] != ELFMAG3 ||
elf64->e_ident[EI_CLASS] != ELFCLASS64 ||
elf64->e_ident[EI_DATA] != ELFDATA2MSB ||
elf64->e_type != ET_EXEC ||
elf64->e_machine != EM_PPC64 )
{
printf("Error: not a valid PPC64 ELF file!\n\r");
exit();
} }
flush_cache(dst, len); elf64ph = (Elf64_Phdr *)((unsigned long)elf64 +
(unsigned long)elf64->e_phoff);
for(i=0; i < (unsigned int)elf64->e_phnum ;i++,elf64ph++) {
if (elf64ph->p_type == PT_LOAD && elf64ph->p_offset != 0)
break;
}
#ifdef DEBUG
printf("... skipping 0x%lx bytes of ELF header\n\r",
(unsigned long)elf64ph->p_offset);
#endif
vmlinux.addr += (unsigned long)elf64ph->p_offset;
vmlinux.size -= (unsigned long)elf64ph->p_offset;
bi_recs = make_bi_recs((unsigned long)dst + vmlinux_end); flush_cache((void *)vmlinux.addr, vmlinux.memsize);
kernel_entry = (kernel_entry_t)dst; bi_recs = make_bi_recs(vmlinux.addr + vmlinux.memsize);
kernel_entry = (kernel_entry_t)vmlinux.addr;
#ifdef DEBUG #ifdef DEBUG
printf( "kernel:\n\r" printf( "kernel:\n\r"
" entry addr = 0x%lx\n\r" " entry addr = 0x%lx\n\r"
...@@ -135,9 +207,9 @@ chrpboot(unsigned long a1, unsigned long a2, void *prom) ...@@ -135,9 +207,9 @@ chrpboot(unsigned long a1, unsigned long a2, void *prom)
kernel_entry( a1, a2, prom, bi_recs ); kernel_entry( a1, a2, prom, bi_recs );
printf("returned?\n\r"); printf("Error: Linux kernel returned to zImage bootloader!\n\r");
pause(); exit();
} }
static struct bi_record * static struct bi_record *
...@@ -162,21 +234,19 @@ make_bi_recs(unsigned long addr) ...@@ -162,21 +234,19 @@ make_bi_recs(unsigned long addr)
rec->data[0] = PLATFORM_PSERIES; rec->data[0] = PLATFORM_PSERIES;
rec->data[1] = 1; rec->data[1] = 1;
if ( initrd_size > 0 ) { if ( initrd.size > 0 ) {
rec = bi_rec_alloc(rec, 2); rec = bi_rec_alloc(rec, 2);
rec->tag = BI_INITRD; rec->tag = BI_INITRD;
rec->data[0] = initrd_start; rec->data[0] = initrd.addr;
rec->data[1] = initrd_size; rec->data[1] = initrd.size;
} }
#if 0 if ( sysmap.size > 0 ) {
if ( sysmap_len > 0 ) {
rec = bi_rec_alloc(rec, 2); rec = bi_rec_alloc(rec, 2);
rec->tag = BI_SYSMAP; rec->tag = BI_SYSMAP;
rec->data[0] = (unsigned long)sysmap_data; rec->data[0] = (unsigned long)sysmap.addr;
rec->data[1] = sysmap_len; rec->data[1] = (unsigned long)sysmap.size;
} }
#endif
rec = bi_rec_alloc(rec, 1); rec = bi_rec_alloc(rec, 1);
rec->tag = BI_LAST; rec->tag = BI_LAST;
......
#ifndef _PPC64_TYPES_H
#define _PPC64_TYPES_H
typedef __signed__ char __s8;
typedef unsigned char __u8;
typedef __signed__ short __s16;
typedef unsigned short __u16;
typedef __signed__ int __s32;
typedef unsigned int __u32;
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#define BITS_PER_LONG 32
#endif /* _PPC64_TYPES_H */
This diff is collapsed.
/*
* Copyright (C) Paul Mackerras 1997.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* NOTE: this code runs in 32 bit mode and is packaged as ELF32.
*/
#include <asm/ppc_asm.h>
.text
.globl strcpy
strcpy:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r5)
bne 1b
blr
.globl strncpy
strncpy:
cmpwi 0,r5,0
beqlr
mtctr r5
addi r6,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r6)
bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
blr
.globl strcat
strcat:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r0,1(r5)
cmpwi 0,r0,0
bne 1b
addi r5,r5,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
stbu r0,1(r5)
bne 1b
blr
.globl strcmp
strcmp:
addi r5,r3,-1
addi r4,r4,-1
1: lbzu r3,1(r5)
cmpwi 1,r3,0
lbzu r0,1(r4)
subf. r3,r0,r3
beqlr 1
beq 1b
blr
.globl strlen
strlen:
addi r4,r3,-1
1: lbzu r0,1(r4)
cmpwi 0,r0,0
bne 1b
subf r3,r3,r4
blr
.globl memset
memset:
rlwimi r4,r4,8,16,23
rlwimi r4,r4,16,0,15
addi r6,r3,-4
cmplwi 0,r5,4
blt 7f
stwu r4,4(r6)
beqlr
andi. r0,r6,3
add r5,r0,r5
subf r6,r0,r6
rlwinm r0,r5,32-2,2,31
mtctr r0
bdz 6f
1: stwu r4,4(r6)
bdnz 1b
6: andi. r5,r5,3
7: cmpwi 0,r5,0
beqlr
mtctr r5
addi r6,r6,3
8: stbu r4,1(r6)
bdnz 8b
blr
.globl bcopy
bcopy:
mr r6,r3
mr r3,r4
mr r4,r6
b memcpy
.globl memmove
memmove:
cmplw 0,r3,r4
bgt backwards_memcpy
/* fall through */
.globl memcpy
memcpy:
rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
addi r6,r3,-4
addi r4,r4,-4
beq 2f /* if less than 8 bytes to do */
andi. r0,r6,3 /* get dest word aligned */
mtctr r7
bne 5f
1: lwz r7,4(r4)
lwzu r8,8(r4)
stw r7,4(r6)
stwu r8,8(r6)
bdnz 1b
andi. r5,r5,7
2: cmplwi 0,r5,4
blt 3f
lwzu r0,4(r4)
addi r5,r5,-4
stwu r0,4(r6)
3: cmpwi 0,r5,0
beqlr
mtctr r5
addi r4,r4,3
addi r6,r6,3
4: lbzu r0,1(r4)
stbu r0,1(r6)
bdnz 4b
blr
5: subfic r0,r0,4
mtctr r0
6: lbz r7,4(r4)
addi r4,r4,1
stb r7,4(r6)
addi r6,r6,1
bdnz 6b
subf r5,r0,r5
rlwinm. r7,r5,32-3,3,31
beq 2b
mtctr r7
b 1b
.globl backwards_memcpy
backwards_memcpy:
rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
add r6,r3,r5
add r4,r4,r5
beq 2f
andi. r0,r6,3
mtctr r7
bne 5f
1: lwz r7,-4(r4)
lwzu r8,-8(r4)
stw r7,-4(r6)
stwu r8,-8(r6)
bdnz 1b
andi. r5,r5,7
2: cmplwi 0,r5,4
blt 3f
lwzu r0,-4(r4)
subi r5,r5,4
stwu r0,-4(r6)
3: cmpwi 0,r5,0
beqlr
mtctr r5
4: lbzu r0,-1(r4)
stbu r0,-1(r6)
bdnz 4b
blr
5: mtctr r0
6: lbzu r7,-1(r4)
stbu r7,-1(r6)
bdnz 6b
subf r5,r0,r5
rlwinm. r7,r5,32-3,3,31
beq 2b
mtctr r7
b 1b
.globl memcmp
memcmp:
cmpwi 0,r5,0
blelr
mtctr r5
addi r6,r3,-1
addi r4,r4,-1
1: lbzu r3,1(r6)
lbzu r0,1(r4)
subf. r3,r0,r3
bdnzt 2,1b
blr
/*
* Flush the dcache and invalidate the icache for a range of addresses.
*
* flush_cache(addr, len)
*/
.global flush_cache
flush_cache:
addi 4,4,0x1f /* len = (len + 0x1f) / 0x20 */
rlwinm. 4,4,27,5,31
mtctr 4
beqlr
1: dcbf 0,3
icbi 0,3
addi 3,3,0x20
bdnz 1b
sync
isync
blr
...@@ -58,6 +58,27 @@ SECTIONS ...@@ -58,6 +58,27 @@ SECTIONS
*(.dynamic) *(.dynamic)
CONSTRUCTORS CONSTRUCTORS
} }
. = ALIGN(4096);
_vmlinux_start = .;
.kernel:vmlinux : { *(.kernel:vmlinux) }
_vmlinux_end = .;
. = ALIGN(4096);
_dotconfig_start = .;
.kernel:.config : { *(.kernel:.config) }
_dotconfig_end = .;
. = ALIGN(4096);
_sysmap_start = .;
.kernel:System.map : { *(.kernel:System.map) }
_sysmap_end = .;
. = ALIGN(4096);
_initrd_start = .;
.kernel:initrd : { *(.kernel:initrd) }
_initrd_end = .;
. = ALIGN(4096); . = ALIGN(4096);
_edata = .; _edata = .;
PROVIDE (edata = .); PROVIDE (edata = .);
......
...@@ -46,6 +46,7 @@ CONFIG_NR_CPUS=32 ...@@ -46,6 +46,7 @@ CONFIG_NR_CPUS=32
# CONFIG_HMT is not set # CONFIG_HMT is not set
# CONFIG_DISCONTIGMEM is not set # CONFIG_DISCONTIGMEM is not set
# CONFIG_RTAS_FLASH is not set # CONFIG_RTAS_FLASH is not set
CONFIG_SCANLOG=y
CONFIG_PPC_RTAS=y CONFIG_PPC_RTAS=y
# #
...@@ -54,7 +55,6 @@ CONFIG_PPC_RTAS=y ...@@ -54,7 +55,6 @@ CONFIG_PPC_RTAS=y
CONFIG_PCI=y CONFIG_PCI=y
CONFIG_KCORE_ELF=y CONFIG_KCORE_ELF=y
CONFIG_BINFMT_ELF=y CONFIG_BINFMT_ELF=y
CONFIG_BINFMT_ELF32=y
# CONFIG_BINFMT_MISC is not set # CONFIG_BINFMT_MISC is not set
CONFIG_PCI_LEGACY_PROC=y CONFIG_PCI_LEGACY_PROC=y
CONFIG_PCI_NAMES=y CONFIG_PCI_NAMES=y
...@@ -137,7 +137,6 @@ CONFIG_CHR_DEV_SG=y ...@@ -137,7 +137,6 @@ CONFIG_CHR_DEV_SG=y
# CONFIG_SCSI_CPQFCTS is not set # CONFIG_SCSI_CPQFCTS is not set
# CONFIG_SCSI_DMX3191D is not set # CONFIG_SCSI_DMX3191D is not set
# CONFIG_SCSI_EATA is not set # CONFIG_SCSI_EATA is not set
# CONFIG_SCSI_EATA_DMA is not set
# CONFIG_SCSI_EATA_PIO is not set # CONFIG_SCSI_EATA_PIO is not set
# CONFIG_SCSI_FUTURE_DOMAIN is not set # CONFIG_SCSI_FUTURE_DOMAIN is not set
# CONFIG_SCSI_GDTH is not set # CONFIG_SCSI_GDTH is not set
...@@ -267,6 +266,7 @@ CONFIG_MII=y ...@@ -267,6 +266,7 @@ CONFIG_MII=y
# CONFIG_SUNGEM is not set # CONFIG_SUNGEM is not set
CONFIG_NET_VENDOR_3COM=y CONFIG_NET_VENDOR_3COM=y
CONFIG_VORTEX=y CONFIG_VORTEX=y
# CONFIG_TYPHOON is not set
# #
# Tulip family network device support # Tulip family network device support
......
...@@ -180,7 +180,7 @@ static struct aligninfo aligninfo[128] = { ...@@ -180,7 +180,7 @@ static struct aligninfo aligninfo[128] = {
#define SWAP(a, b) (t = (a), (a) = (b), (b) = t) #define SWAP(a, b) (t = (a), (a) = (b), (b) = t)
unsigned static inline make_dsisr( unsigned instr ) static inline unsigned make_dsisr(unsigned instr)
{ {
unsigned dsisr; unsigned dsisr;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/sys.h> #include <asm/unistd.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/mmu.h> #include <asm/mmu.h>
...@@ -301,6 +301,8 @@ _GLOBAL(_switch) ...@@ -301,6 +301,8 @@ _GLOBAL(_switch)
REST_8GPRS(14, r1) REST_8GPRS(14, r1)
REST_10GPRS(22, r1) REST_10GPRS(22, r1)
/* convert old thread to its task_struct for return value */
addi r3,r3,-THREAD
ld r7,_NIP(r1) /* Return to _switch caller in new task */ ld r7,_NIP(r1) /* Return to _switch caller in new task */
mtlr r7 mtlr r7
addi r1,r1,SWITCH_FRAME_SIZE addi r1,r1,SWITCH_FRAME_SIZE
...@@ -391,6 +393,11 @@ restore: ...@@ -391,6 +393,11 @@ restore:
stb r0,PACAPROCENABLED(r13) stb r0,PACAPROCENABLED(r13)
#endif #endif
mfmsr r0
li r2, MSR_RI
andc r0,r0,r2
mtmsrd r0
ld r0,_MSR(r1) ld r0,_MSR(r1)
mtspr SRR1,r0 mtspr SRR1,r0
...@@ -487,8 +494,9 @@ _GLOBAL(enter_rtas) ...@@ -487,8 +494,9 @@ _GLOBAL(enter_rtas)
li r9,1 li r9,1
rldicr r9,r9,MSR_SF_LG,(63-MSR_SF_LG) rldicr r9,r9,MSR_SF_LG,(63-MSR_SF_LG)
ori r9,r9,MSR_IR|MSR_DR|MSR_FE0|MSR_FE1|MSR_FP|MSR_RI ori r9,r9,MSR_IR|MSR_DR|MSR_FE0|MSR_FE1|MSR_FP
andc r6,r0,r9 andc r6,r0,r9
ori r6,r6,MSR_RI
sync /* disable interrupts so SRR0/1 */ sync /* disable interrupts so SRR0/1 */
mtmsrd r0 /* don't get trashed */ mtmsrd r0 /* don't get trashed */
......
...@@ -189,12 +189,20 @@ _GLOBAL(__secondary_hold) ...@@ -189,12 +189,20 @@ _GLOBAL(__secondary_hold)
std r22,EX_SRR0(r21); /* Save SRR0 in exc. frame */ \ std r22,EX_SRR0(r21); /* Save SRR0 in exc. frame */ \
mfspr r23,SRR1; /* machine state at interrupt */ \ mfspr r23,SRR1; /* machine state at interrupt */ \
std r23,EX_SRR1(r21); /* Save SRR1 in exc. frame */ \ std r23,EX_SRR1(r21); /* Save SRR1 in exc. frame */ \
\
mfspr r23,DAR; /* Save DAR in exc. frame */ \
std r23,EX_DAR(r21); \
mfspr r23,DSISR; /* Save DSISR in exc. frame */ \
stw r23,EX_DSISR(r21); \
mfspr r23,SPRG2; /* Save r20 in exc. frame */ \
std r23,EX_R20(r21); \
\
clrrdi r22,r20,60; /* Get 0xc part of the vaddr */ \ clrrdi r22,r20,60; /* Get 0xc part of the vaddr */ \
ori r22,r22,(label)@l; /* add in the vaddr offset */ \ ori r22,r22,(label)@l; /* add in the vaddr offset */ \
/* assumes *_common < 16b */ \ /* assumes *_common < 16b */ \
mfmsr r23; \ mfmsr r23; \
rotldi r23,r23,4; \ rotldi r23,r23,4; \
ori r23,r23,0x30B; /* Set IR, DR, SF, ISF, HV */ \ ori r23,r23,0x32B; /* Set IR, DR, RI, SF, ISF, HV*/ \
rotldi r23,r23,60; /* for generic handlers */ \ rotldi r23,r23,60; /* for generic handlers */ \
mtspr SRR0,r22; \ mtspr SRR0,r22; \
mtspr SRR1,r23; \ mtspr SRR1,r23; \
...@@ -231,16 +239,10 @@ _GLOBAL(__secondary_hold) ...@@ -231,16 +239,10 @@ _GLOBAL(__secondary_hold)
* frame on entry, r23 contains the saved CR, and relocation is on. * frame on entry, r23 contains the saved CR, and relocation is on.
*/ */
#define EXCEPTION_PROLOG_COMMON \ #define EXCEPTION_PROLOG_COMMON \
mfspr r22,SPRG2; /* Save r20 in exc. frame */ \
std r22,EX_R20(r21); \
mfspr r22,SPRG1; /* Save r21 in exc. frame */ \ mfspr r22,SPRG1; /* Save r21 in exc. frame */ \
std r22,EX_R21(r21); \ std r22,EX_R21(r21); \
mfspr r22,DAR; /* Save DAR in exc. frame */ \
std r22,EX_DAR(r21); \
std r21,PACAEXCSP(r20); /* update exception stack ptr */ \ std r21,PACAEXCSP(r20); /* update exception stack ptr */ \
/* iff no protection flt */ \ /* iff no protection flt */ \
mfspr r22,DSISR; /* Save DSISR in exc. frame */ \
stw r22,EX_DSISR(r21); \
ld r22,EX_SRR1(r21); /* Get SRR1 from exc. frame */ \ ld r22,EX_SRR1(r21); /* Get SRR1 from exc. frame */ \
andi. r22,r22,MSR_PR; /* Set CR for later branch */ \ andi. r22,r22,MSR_PR; /* Set CR for later branch */ \
mr r22,r1; /* Save r1 */ \ mr r22,r1; /* Save r1 */ \
...@@ -556,6 +558,12 @@ fast_exception_return: ...@@ -556,6 +558,12 @@ fast_exception_return:
REST_GPR(0, r1) REST_GPR(0, r1)
REST_8GPRS(2, r1) REST_8GPRS(2, r1)
REST_4GPRS(10, r1) REST_4GPRS(10, r1)
mfmsr r20
li r21, MSR_RI
andc r20,r20,r21
mtmsrd r20
mtspr SRR1,r23 mtspr SRR1,r23
mtspr SRR0,r22 mtspr SRR0,r22
REST_4GPRS(20, r1) REST_4GPRS(20, r1)
...@@ -977,6 +985,12 @@ _GLOBAL(do_stab_bolted) ...@@ -977,6 +985,12 @@ _GLOBAL(do_stab_bolted)
lwz r23,EX_CCR(r21) /* get saved CR */ lwz r23,EX_CCR(r21) /* get saved CR */
/* note that this is almost identical to maskable_exception_exit */ /* note that this is almost identical to maskable_exception_exit */
mtcr r23 /* restore CR */ mtcr r23 /* restore CR */
mfmsr r22
li r23, MSR_RI
andc r22,r22,r23
mtmsrd r22
ld r22,EX_SRR0(r21) /* Get SRR0 from exc. frame */ ld r22,EX_SRR0(r21) /* Get SRR0 from exc. frame */
ld r23,EX_SRR1(r21) /* Get SRR1 from exc. frame */ ld r23,EX_SRR1(r21) /* Get SRR1 from exc. frame */
mtspr SRR0,r22 mtspr SRR0,r22
...@@ -1076,6 +1090,12 @@ SLB_NUM_ENTRIES = 64 ...@@ -1076,6 +1090,12 @@ SLB_NUM_ENTRIES = 64
lwz r23,EX_CCR(r21) /* get saved CR */ lwz r23,EX_CCR(r21) /* get saved CR */
/* note that this is almost identical to maskable_exception_exit */ /* note that this is almost identical to maskable_exception_exit */
mtcr r23 /* restore CR */ mtcr r23 /* restore CR */
mfmsr r22
li r23, MSR_RI
andc r22,r22,r23
mtmsrd r22
ld r22,EX_SRR0(r21) /* Get SRR0 from exc. frame */ ld r22,EX_SRR0(r21) /* Get SRR0 from exc. frame */
ld r23,EX_SRR1(r21) /* Get SRR1 from exc. frame */ ld r23,EX_SRR1(r21) /* Get SRR1 from exc. frame */
mtspr SRR0,r22 mtspr SRR0,r22
...@@ -1189,7 +1209,6 @@ do_profile: ...@@ -1189,7 +1209,6 @@ do_profile:
* At entry, r3 = this processor's number (in Linux terms, not hardware). * At entry, r3 = this processor's number (in Linux terms, not hardware).
*/ */
_GLOBAL(pseries_secondary_smp_init) _GLOBAL(pseries_secondary_smp_init)
/* turn on 64-bit mode */ /* turn on 64-bit mode */
bl .enable_64b_mode bl .enable_64b_mode
isync isync
...@@ -1543,15 +1562,23 @@ _GLOBAL(__secondary_start) ...@@ -1543,15 +1562,23 @@ _GLOBAL(__secondary_start)
sc /* HvCall_setASR */ sc /* HvCall_setASR */
#else #else
/* set the ASR */ /* set the ASR */
addi r3,0,0x4000 /* r3 = ptr to naca */ addi r3,0,0x4000 /* r3 = ptr to naca */
lhz r3,PLATFORM(r3) /* r3 = platform flags */ lhz r3,PLATFORM(r3) /* r3 = platform flags */
cmpldi r3,PLATFORM_PSERIES_LPAR cmpldi r3,PLATFORM_PSERIES_LPAR
bne 98f bne 98f
li r3,H_SET_ASR /* hcall = H_SET_ASR */ mfspr r3,PVR
HSC /* Invoking hcall */ srwi r3,r3,16
b 99f cmpwi r3,0x37 /* SStar */
98: /* This is not a hypervisor machine */ beq 97f
mtasr r4 /* set the stab location */ cmpwi r3,0x36 /* IStar */
beq 97f
cmpwi r3,0x34 /* Pulsar */
bne 98f
97: li r3,H_SET_ASR /* hcall = H_SET_ASR */
HSC /* Invoking hcall */
b 99f
98: /* !(rpa hypervisor) || !(star) */
mtasr r4 /* set the stab location */
99: 99:
#endif #endif
li r7,0 li r7,0
...@@ -1689,15 +1716,23 @@ _STATIC(start_here_pSeries) ...@@ -1689,15 +1716,23 @@ _STATIC(start_here_pSeries)
ori r4,r3,1 /* turn on valid bit */ ori r4,r3,1 /* turn on valid bit */
/* set the ASR */ /* set the ASR */
addi r3,0,0x4000 /* r3 = ptr to naca */ addi r3,0,0x4000 /* r3 = ptr to naca */
lhz r3,PLATFORM(r3) /* r3 = platform flags */ lhz r3,PLATFORM(r3) /* r3 = platform flags */
cmpldi r3,PLATFORM_PSERIES_LPAR cmpldi r3,PLATFORM_PSERIES_LPAR
bne 98f bne 98f
li r3,H_SET_ASR /* hcall = H_SET_ASR */ mfspr r3,PVR
HSC /* Invoking hcall */ srwi r3,r3,16
b 99f cmpwi r3,0x37 /* SStar */
98: /* This is not a hypervisor machine */ beq 97f
mtasr r4 /* set the stab location */ cmpwi r3,0x36 /* IStar */
beq 97f
cmpwi r3,0x34 /* Pulsar */
bne 98f
97: li r3,H_SET_ASR /* hcall = H_SET_ASR */
HSC /* Invoking hcall */
b 99f
98: /* !(rpa hypervisor) || !(star) */
mtasr r4 /* set the stab location */
99: 99:
mfspr r6,SPRG3 mfspr r6,SPRG3
ld r3,PACASTABREAL(r6) /* restore r3 for stab_initialize */ ld r3,PACASTABREAL(r6) /* restore r3 for stab_initialize */
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/eeh.h> #include <asm/eeh.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/cacheflush.h>
/* /*
* Note: pte --> Linux PTE * Note: pte --> Linux PTE
...@@ -348,6 +349,9 @@ int __hash_page(unsigned long ea, unsigned long access, unsigned long vsid, ...@@ -348,6 +349,9 @@ int __hash_page(unsigned long ea, unsigned long access, unsigned long vsid,
} }
} }
if (unlikely(slot == -2))
panic("hash_page: pte_insert failed\n");
pte_val(new_pte) |= (slot<<12) & _PAGE_GROUP_IX; pte_val(new_pte) |= (slot<<12) & _PAGE_GROUP_IX;
/* /*
......
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci.h> #include <net/bluetooth/hci.h>
#include <net/bluetooth/rfcomm.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
...@@ -3633,6 +3634,15 @@ static int do_blkgetsize64(unsigned int fd, unsigned int cmd, ...@@ -3633,6 +3634,15 @@ static int do_blkgetsize64(unsigned int fd, unsigned int cmd,
return sys_ioctl(fd, BLKGETSIZE64, arg); return sys_ioctl(fd, BLKGETSIZE64, arg);
} }
/* Bluetooth ioctls */
#define HCIUARTSETPROTO _IOW('U', 200, int)
#define HCIUARTGETPROTO _IOR('U', 201, int)
#define BNEPCONNADD _IOW('B', 200, int)
#define BNEPCONNDEL _IOW('B', 201, int)
#define BNEPGETCONNLIST _IOR('B', 210, int)
#define BNEPGETCONNINFO _IOR('B', 211, int)
struct ioctl_trans { struct ioctl_trans {
unsigned long cmd; unsigned long cmd;
unsigned long handler; unsigned long handler;
...@@ -4241,6 +4251,17 @@ COMPATIBLE_IOCTL(HCISETLINKMODE), ...@@ -4241,6 +4251,17 @@ COMPATIBLE_IOCTL(HCISETLINKMODE),
COMPATIBLE_IOCTL(HCISETACLMTU), COMPATIBLE_IOCTL(HCISETACLMTU),
COMPATIBLE_IOCTL(HCISETSCOMTU), COMPATIBLE_IOCTL(HCISETSCOMTU),
COMPATIBLE_IOCTL(HCIINQUIRY), COMPATIBLE_IOCTL(HCIINQUIRY),
COMPATIBLE_IOCTL(HCIUARTSETPROTO),
COMPATIBLE_IOCTL(HCIUARTGETPROTO),
COMPATIBLE_IOCTL(RFCOMMCREATEDEV),
COMPATIBLE_IOCTL(RFCOMMRELEASEDEV),
COMPATIBLE_IOCTL(RFCOMMGETDEVLIST),
COMPATIBLE_IOCTL(RFCOMMGETDEVINFO),
COMPATIBLE_IOCTL(RFCOMMSTEALDLC),
COMPATIBLE_IOCTL(BNEPCONNADD),
COMPATIBLE_IOCTL(BNEPCONNDEL),
COMPATIBLE_IOCTL(BNEPGETCONNLIST),
COMPATIBLE_IOCTL(BNEPGETCONNINFO),
COMPATIBLE_IOCTL(PCIIOC_CONTROLLER), COMPATIBLE_IOCTL(PCIIOC_CONTROLLER),
COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO), COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO),
COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM), COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM),
......
...@@ -743,10 +743,6 @@ _GLOBAL(sys_call_table32) ...@@ -743,10 +743,6 @@ _GLOBAL(sys_call_table32)
.llong .sys_epoll_wait .llong .sys_epoll_wait
.llong .sys_remap_file_pages .llong .sys_remap_file_pages
.rept NR_syscalls-239
.llong .sys_ni_syscall
.endr
.balign 8 .balign 8
_GLOBAL(sys_call_table) _GLOBAL(sys_call_table)
.llong .sys_restart_syscall /* 0 */ .llong .sys_restart_syscall /* 0 */
...@@ -989,7 +985,3 @@ _GLOBAL(sys_call_table) ...@@ -989,7 +985,3 @@ _GLOBAL(sys_call_table)
.llong .sys_epoll_ctl .llong .sys_epoll_ctl
.llong .sys_epoll_wait .llong .sys_epoll_wait
.llong .sys_remap_file_pages .llong .sys_remap_file_pages
.rept NR_syscalls-239
.llong .sys_ni_syscall
.endr
...@@ -555,14 +555,15 @@ void openpic_request_IPIs(void) ...@@ -555,14 +555,15 @@ void openpic_request_IPIs(void)
if (OpenPIC == NULL) if (OpenPIC == NULL)
return; return;
request_irq(openpic_vec_ipi, /* IPIs are marked SA_INTERRUPT as they must run with irqs disabled */
openpic_ipi_action, 0, "IPI0 (call function)", 0); request_irq(openpic_vec_ipi, openpic_ipi_action, SA_INTERRUPT,
request_irq(openpic_vec_ipi+1, "IPI0 (call function)", 0);
openpic_ipi_action, 0, "IPI1 (reschedule)", 0); request_irq(openpic_vec_ipi+1, openpic_ipi_action, SA_INTERRUPT,
request_irq(openpic_vec_ipi+2, "IPI1 (reschedule)", 0);
openpic_ipi_action, 0, "IPI2 (invalidate tlb)", 0); request_irq(openpic_vec_ipi+2, openpic_ipi_action, SA_INTERRUPT,
request_irq(openpic_vec_ipi+3, "IPI2 (invalidate tlb)", 0);
openpic_ipi_action, 0, "IPI3 (xmon break)", 0); request_irq(openpic_vec_ipi+3, openpic_ipi_action, SA_INTERRUPT,
"IPI3 (xmon break)", 0);
for ( i = 0; i < OPENPIC_NUM_IPI ; i++ ) for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )
openpic_enable_ipi(openpic_vec_ipi+i); openpic_enable_ipi(openpic_vec_ipi+i);
...@@ -754,17 +755,12 @@ static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask) ...@@ -754,17 +755,12 @@ static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static void openpic_end_ipi(unsigned int irq_nr) static void openpic_end_ipi(unsigned int irq_nr)
{ {
/* IPIs are marked IRQ_PER_CPU. This has the side effect of /*
* IPIs are marked IRQ_PER_CPU. This has the side effect of
* preventing the IRQ_PENDING/IRQ_INPROGRESS logic from * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from
* applying to them. We EOI them late to avoid re-entering. * applying to them. We EOI them late to avoid re-entering.
* however, I'm wondering if we could simply let them have the * We mark IPI's with SA_INTERRUPT as they must run with
* SA_INTERRUPT flag and let them execute with all interrupts OFF. * irqs disabled.
* This would have the side effect of either running cross-CPU
* functions with interrupts off, or we can re-enable them explicitely
* with a local_irq_enable() in smp_call_function_interrupt(), since
* smp_call_function() is protected by a spinlock.
* Or maybe we shouldn't set the IRQ_PER_CPU flag on cross-CPU
* function calls IPI at all but that would make a special case.
*/ */
openpic_eoi(); openpic_eoi();
} }
......
...@@ -460,8 +460,13 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group, ...@@ -460,8 +460,13 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
if (lpar_rc == H_PTEG_Full) if (lpar_rc == H_PTEG_Full)
return -1; return -1;
/*
* Since we try and ioremap PHBs we dont own, the pte insert
* will fail. However we must catch the failure in hash_page
* or we will loop forever, so return -2 in this case.
*/
if (lpar_rc != H_Success) if (lpar_rc != H_Success)
panic("Bad return code from pte enter rc = %lx\n", lpar_rc); return -2;
return slot; return slot;
} }
......
...@@ -82,11 +82,12 @@ dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) ...@@ -82,11 +82,12 @@ dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs)
return 1; return 1;
} }
void struct task_struct *__switch_to(struct task_struct *prev,
__switch_to(struct task_struct *prev, struct task_struct *new) struct task_struct *new)
{ {
struct thread_struct *new_thread, *old_thread; struct thread_struct *new_thread, *old_thread;
unsigned long flags; unsigned long flags;
struct task_struct *last;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* avoid complexity of lazy save/restore of fpu /* avoid complexity of lazy save/restore of fpu
...@@ -106,8 +107,9 @@ __switch_to(struct task_struct *prev, struct task_struct *new) ...@@ -106,8 +107,9 @@ __switch_to(struct task_struct *prev, struct task_struct *new)
old_thread = &current->thread; old_thread = &current->thread;
local_irq_save(flags); local_irq_save(flags);
_switch(old_thread, new_thread); last = _switch(old_thread, new_thread);
local_irq_restore(flags); local_irq_restore(flags);
return last;
} }
static void show_tsk_stack(struct task_struct *p, unsigned long sp); static void show_tsk_stack(struct task_struct *p, unsigned long sp);
...@@ -237,22 +239,30 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp, ...@@ -237,22 +239,30 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
/* /*
* Set up a thread for executing a new program * Set up a thread for executing a new program
*/ */
void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp) void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp)
{ {
/* NIP is *really* a pointer to the function descriptor for unsigned long entry, toc, load_addr = regs->gpr[2];
/* fdptr is a relocated pointer to the function descriptor for
* the elf _start routine. The first entry in the function * the elf _start routine. The first entry in the function
* descriptor is the entry address of _start and the second * descriptor is the entry address of _start and the second
* entry is the TOC value we need to use. * entry is the TOC value we need to use.
*/ */
unsigned long *entry = (unsigned long *)nip;
unsigned long *toc = entry + 1;
set_fs(USER_DS); set_fs(USER_DS);
memset(regs->gpr, 0, sizeof(regs->gpr)); __get_user(entry, (unsigned long *)fdptr);
memset(&regs->ctr, 0, 4 * sizeof(regs->ctr)); __get_user(toc, (unsigned long *)fdptr+1);
__get_user(regs->nip, entry);
/* Check whether the e_entry function descriptor entries
* need to be relocated before we can use them.
*/
if ( load_addr != 0 ) {
entry += load_addr;
toc += load_addr;
}
regs->nip = entry;
regs->gpr[1] = sp; regs->gpr[1] = sp;
__get_user(regs->gpr[2], toc); regs->gpr[2] = toc;
regs->msr = MSR_USER64; regs->msr = MSR_USER64;
if (last_task_used_math == current) if (last_task_used_math == current)
last_task_used_math = 0; last_task_used_math = 0;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#define DEBUG_SIG 0
#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
/* /*
* These are the flags in the MSR that the user is allowed to change * These are the flags in the MSR that the user is allowed to change
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <asm/time.h> #include <asm/time.h>
extern unsigned long wall_jiffies; extern unsigned long wall_jiffies;
#define USEC_PER_SEC (1000000)
void void
check_bugs(void) check_bugs(void)
......
...@@ -77,7 +77,6 @@ static unsigned long first_settimeofday = 1; ...@@ -77,7 +77,6 @@ static unsigned long first_settimeofday = 1;
#endif #endif
#define XSEC_PER_SEC (1024*1024) #define XSEC_PER_SEC (1024*1024)
#define USEC_PER_SEC (1000000)
unsigned long tb_ticks_per_jiffy; unsigned long tb_ticks_per_jiffy;
unsigned long tb_ticks_per_usec; unsigned long tb_ticks_per_usec;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/signal.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -423,8 +424,11 @@ xics_init_IRQ( void ) ...@@ -423,8 +424,11 @@ xics_init_IRQ( void )
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
real_irq_to_virt_map[XICS_IPI] = virt_irq_to_real_map[XICS_IPI] = XICS_IPI; real_irq_to_virt_map[XICS_IPI] = virt_irq_to_real_map[XICS_IPI] =
request_irq(XICS_IPI + XICS_IRQ_OFFSET, xics_ipi_action, 0, "IPI", 0); XICS_IPI;
/* IPIs are marked SA_INTERRUPT as they must run with irqs disabled */
request_irq(XICS_IPI + XICS_IRQ_OFFSET, xics_ipi_action, SA_INTERRUPT,
"IPI", 0);
irq_desc[XICS_IPI+XICS_IRQ_OFFSET].status |= IRQ_PER_CPU; irq_desc[XICS_IPI+XICS_IRQ_OFFSET].status |= IRQ_PER_CPU;
#endif #endif
ppc64_boot_msg(0x21, "XICS Done"); ppc64_boot_msg(0x21, "XICS Done");
......
...@@ -233,6 +233,7 @@ static void map_io_page(unsigned long ea, unsigned long pa, int flags) ...@@ -233,6 +233,7 @@ static void map_io_page(unsigned long ea, unsigned long pa, int flags)
hpteg = ((hash & htab_data.htab_hash_mask)*HPTES_PER_GROUP); hpteg = ((hash & htab_data.htab_hash_mask)*HPTES_PER_GROUP);
/* Panic if a pte grpup is full */
if (ppc_md.hpte_insert(hpteg, va, pa >> PAGE_SHIFT, 0, if (ppc_md.hpte_insert(hpteg, va, pa >> PAGE_SHIFT, 0,
_PAGE_NO_CACHE|_PAGE_GUARDED|PP_RWXX, _PAGE_NO_CACHE|_PAGE_GUARDED|PP_RWXX,
1, 0) == -1) { 1, 0) == -1) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/profile.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
static int timer_notify(struct notifier_block * self, unsigned long val, void * data) static int timer_notify(struct notifier_block * self, unsigned long val, void * data)
......
...@@ -84,6 +84,11 @@ ppc64_elf_core_copy_regs(elf_gregset_t dstRegs, struct pt_regs* srcRegs) ...@@ -84,6 +84,11 @@ ppc64_elf_core_copy_regs(elf_gregset_t dstRegs, struct pt_regs* srcRegs)
#define ELF_PLATFORM (NULL) #define ELF_PLATFORM (NULL)
#define ELF_PLAT_INIT(_r) do { \
memset(_r->gpr, 0, sizeof(_r->gpr)); \
_r->ctr = _r->link = _r->xer = _r->ccr = 0; \
} while (0)
#ifdef __KERNEL__ #ifdef __KERNEL__
#define SET_PERSONALITY(ex, ibcs2) \ #define SET_PERSONALITY(ex, ibcs2) \
do { \ do { \
......
...@@ -82,7 +82,7 @@ typedef struct { ...@@ -82,7 +82,7 @@ typedef struct {
#define irq_enter() (preempt_count() += HARDIRQ_OFFSET) #define irq_enter() (preempt_count() += HARDIRQ_OFFSET)
#if CONFIG_PREEMPT #ifdef CONFIG_PREEMPT
# define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked()) # define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
# define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1) # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
#else #else
......
...@@ -26,6 +26,8 @@ typedef unsigned long __kernel_size_t; ...@@ -26,6 +26,8 @@ typedef unsigned long __kernel_size_t;
typedef long __kernel_ssize_t; typedef long __kernel_ssize_t;
typedef long __kernel_ptrdiff_t; typedef long __kernel_ptrdiff_t;
typedef long __kernel_time_t; typedef long __kernel_time_t;
typedef int __kernel_timer_t;
typedef int __kernel_clockid_t;
typedef long __kernel_suseconds_t; typedef long __kernel_suseconds_t;
typedef long __kernel_clock_t; typedef long __kernel_clock_t;
typedef int __kernel_daddr_t; typedef int __kernel_daddr_t;
......
...@@ -598,7 +598,7 @@ GLUE(GLUE(.LT,NAME),_procname_end): ...@@ -598,7 +598,7 @@ GLUE(GLUE(.LT,NAME),_procname_end):
extern int have_of; extern int have_of;
struct task_struct; struct task_struct;
void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp); void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
void release_thread(struct task_struct *); void release_thread(struct task_struct *);
/* /*
......
...@@ -23,12 +23,12 @@ struct semaphore { ...@@ -23,12 +23,12 @@ struct semaphore {
*/ */
atomic_t count; atomic_t count;
wait_queue_head_t wait; wait_queue_head_t wait;
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
long __magic; long __magic;
#endif #endif
}; };
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
# define __SEM_DEBUG_INIT(name) \ # define __SEM_DEBUG_INIT(name) \
, (long)&(name).__magic , (long)&(name).__magic
#else #else
...@@ -53,7 +53,7 @@ static inline void sema_init (struct semaphore *sem, int val) ...@@ -53,7 +53,7 @@ static inline void sema_init (struct semaphore *sem, int val)
{ {
atomic_set(&sem->count, val); atomic_set(&sem->count, val);
init_waitqueue_head(&sem->wait); init_waitqueue_head(&sem->wait);
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
sem->__magic = (long)&sem->__magic; sem->__magic = (long)&sem->__magic;
#endif #endif
} }
...@@ -74,7 +74,7 @@ extern void __up(struct semaphore * sem); ...@@ -74,7 +74,7 @@ extern void __up(struct semaphore * sem);
static inline void down(struct semaphore * sem) static inline void down(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
might_sleep(); might_sleep();
...@@ -91,7 +91,7 @@ static inline int down_interruptible(struct semaphore * sem) ...@@ -91,7 +91,7 @@ static inline int down_interruptible(struct semaphore * sem)
{ {
int ret = 0; int ret = 0;
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
might_sleep(); might_sleep();
...@@ -106,7 +106,7 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -106,7 +106,7 @@ static inline int down_trylock(struct semaphore * sem)
{ {
int ret; int ret;
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
...@@ -117,7 +117,7 @@ static inline int down_trylock(struct semaphore * sem) ...@@ -117,7 +117,7 @@ static inline int down_trylock(struct semaphore * sem)
static inline void up(struct semaphore * sem) static inline void up(struct semaphore * sem)
{ {
#if WAITQUEUE_DEBUG #ifdef WAITQUEUE_DEBUG
CHECK_MAGIC(sem->__magic); CHECK_MAGIC(sem->__magic);
#endif #endif
......
...@@ -89,11 +89,13 @@ extern void cvt_df(double *from, float *to, unsigned long *fpscr); ...@@ -89,11 +89,13 @@ extern void cvt_df(double *from, float *to, unsigned long *fpscr);
extern int abs(int); extern int abs(int);
struct task_struct; struct task_struct;
extern void __switch_to(struct task_struct *, struct task_struct *); extern struct task_struct *__switch_to(struct task_struct *,
#define switch_to(prev, next, last) __switch_to((prev), (next)) struct task_struct *);
#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
struct thread_struct; struct thread_struct;
extern void _switch(struct thread_struct *prev, struct thread_struct *next); extern struct task_struct * _switch(struct thread_struct *prev,
struct thread_struct *next);
struct pt_regs; struct pt_regs;
extern void dump_regs(struct pt_regs *); extern void dump_regs(struct pt_regs *);
......
...@@ -250,6 +250,22 @@ ...@@ -250,6 +250,22 @@
#define __NR_sys_epoll_ctl 237 #define __NR_sys_epoll_ctl 237
#define __NR_sys_epoll_wait 238 #define __NR_sys_epoll_wait 238
#define __NR_remap_file_pages 239 #define __NR_remap_file_pages 239
#define __NR_timer_create 240
#define __NR_timer_settime 241
#define __NR_timer_gettime 242
#define __NR_timer_getoverrun 243
#define __NR_timer_delete 244
#define __NR_clock_settime 245
#define __NR_clock_gettime 246
#define __NR_clock_getres 247
#define __NR_clock_nanosleep 248
#define __NR_syscalls 249
#ifdef __KERNEL__
#define NR_syscalls __NR_syscalls
#endif
#ifndef __ASSEMBLY__
#ifdef __KERNEL_SYSCALLS__ #ifdef __KERNEL_SYSCALLS__
...@@ -284,4 +300,6 @@ extern pid_t waitpid(pid_t pid, int *wait_stat, int options); ...@@ -284,4 +300,6 @@ extern pid_t waitpid(pid_t pid, int *wait_stat, int options);
*/ */
#define cond_syscall(x) asm(".weak\t." #x "\n\t.set\t." #x ",.sys_ni_syscall"); #define cond_syscall(x) asm(".weak\t." #x "\n\t.set\t." #x ",.sys_ni_syscall");
#endif /* __ASSEMBLY__ */
#endif /* _ASM_PPC_UNISTD_H_ */ #endif /* _ASM_PPC_UNISTD_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment