diff options
author | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-10-08 14:42:10 +0000 |
---|---|---|
committer | Per Fogelstrom <pefo@cvs.openbsd.org> | 2004-10-08 14:42:10 +0000 |
commit | a4ea5162336e8d17a642c9c05ee7242e33d12238 (patch) | |
tree | afc3b9e715520e2156f77936041e673efffc9b0a | |
parent | 7a0b2ae53cd711aa9881f8134c8c0449b50be7de (diff) |
64 bit safe over entire address range
-rw-r--r-- | sys/lib/libkern/arch/mips64/bcmp.S | 44 | ||||
-rw-r--r-- | sys/lib/libkern/arch/mips64/bcopy.S | 46 | ||||
-rw-r--r-- | sys/lib/libkern/arch/mips64/bzero.S | 30 | ||||
-rw-r--r-- | sys/lib/libkern/arch/mips64/strcmp.S | 10 | ||||
-rw-r--r-- | sys/lib/libkern/arch/mips64/strlen.S | 8 |
5 files changed, 69 insertions, 69 deletions
diff --git a/sys/lib/libkern/arch/mips64/bcmp.S b/sys/lib/libkern/arch/mips64/bcmp.S index da6e25b0c14..5f5dcd755db 100644 --- a/sys/lib/libkern/arch/mips64/bcmp.S +++ b/sys/lib/libkern/arch/mips64/bcmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bcmp.S,v 1.3 2004/09/09 15:41:18 pefo Exp $ */ +/* $OpenBSD: bcmp.S,v 1.4 2004/10/08 14:42:09 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -42,72 +42,72 @@ LEAF(bcmp, 0) blt a2, 16, smallcmp # is it worth any trouble? xor v0, a0, a1 # compare low two bits of addresses and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address + PTR_SUBU a3, zero, a1 # compute # bytes to word align address bne v0, zero, unalignedcmp # not possible to align addresses and a3, a3, 3 beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + PTR_SUBU a2, a2, a3 # subtract from remaining count move v0, v1 # init v0,v1 so unmodified bytes match LWHI v0, 0(a0) # read 1, 2, or 3 bytes LWHI v1, 0(a1) - addu a1, a1, a3 + PTR_ADDU a1, a1, a3 bne v0, v1, nomatch - addu a0, a0, a3 + PTR_ADDU a0, a0, a3 1: and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address + PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 + PTR_ADDU a3, a3, a0 # compute ending address 2: lw v0, 0(a0) # compare words lw v1, 0(a1) - addu a0, a0, 4 + PTR_ADDU a0, a0, 4 bne v0, v1, nomatch - addu a1, a1, 4 + PTR_ADDU a1, a1, 4 bne a0, a3, 2b nop b smallcmp # finish remainder nop unalignedcmp: beq a3, zero, 2f - subu a2, a2, a3 # subtract from remaining count - addu a3, a3, a0 # compute ending address + PTR_SUBU a2, a2, a3 # subtract from remaining count + PTR_ADDU a3, a3, a0 # compute ending address 1: lbu v0, 0(a0) # compare bytes until a1 word aligned lbu v1, 0(a1) - addu a0, a0, 1 + PTR_ADDU a0, a0, 1 bne v0, v1, nomatch - addu a1, a1, 1 + PTR_ADDU a1, a1, 1 bne a0, a3, 1b nop 2: and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address + PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 + PTR_ADDU a3, a3, a0 # compute ending address 3: LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned LWLO v0, 3(a0) lw v1, 0(a1) - addu a0, a0, 4 + PTR_ADDU a0, a0, 4 bne v0, v1, nomatch - addu a1, a1, 4 + PTR_ADDU a1, a1, 4 bne a0, a3, 3b nop smallcmp: ble a2, zero, match - addu a3, a2, a0 # compute ending address + PTR_ADDU a3, a2, a0 # compute ending address 1: lbu v0, 0(a0) lbu v1, 0(a1) - addu a0, a0, 1 + PTR_ADDU a0, a0, 1 bne v0, v1, nomatch - addu a1, a1, 1 + PTR_ADDU a1, a1, 1 bne a0, a3, 1b nop match: j ra - move v0, zero + move v0, zero nomatch: j ra - li v0, 1 + dli v0, 1 END(bcmp) diff --git a/sys/lib/libkern/arch/mips64/bcopy.S b/sys/lib/libkern/arch/mips64/bcopy.S index b48fe7504eb..6ee62c945cc 100644 --- a/sys/lib/libkern/arch/mips64/bcopy.S +++ b/sys/lib/libkern/arch/mips64/bcopy.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bcopy.S,v 1.3 2004/09/09 15:41:18 pefo Exp $ */ +/* $OpenBSD: bcopy.S,v 1.4 2004/10/08 14:42:09 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -46,7 +46,7 @@ LEAF(memcpy, 0) ALEAF(bcopy) ALEAF(ovbcopy) .set noreorder - addu t0, a0, a2 # t0 = end of s1 region + PTR_ADDU t0, a0, a2 # t0 = end of s1 region sltu t1, a1, t0 sltu t2, a0, a1 and t1, t1, t2 # t1 = true if from < to < (from+len) @@ -54,11 +54,11 @@ ALEAF(ovbcopy) slt t2, a2, 12 # check for small copy ble a2, zero, 2f - addu t1, a1, a2 # t1 = end of to region + PTR_ADDU t1, a1, a2 # t1 = end of to region 1: lb v1, -1(t0) # copy bytes backwards, - subu t0, t0, 1 # doesnt happen often so do slow way - subu t1, t1, 1 + PTR_SUBU t0, t0, 1 # doesnt happen often so do slow way + PTR_SUBU t1, t1, 1 bne t0, a0, 1b sb v1, 0(t1) 2: @@ -68,59 +68,59 @@ forward: bne t2, zero, smallcpy # do a small bcopy xor v1, a0, a1 # compare low two bits of addresses and v1, v1, 3 - subu a3, zero, a1 # compute # bytes to word align address + PTR_SUBU a3, zero, a1 # compute # bytes to word align address beq v1, zero, aligned # addresses can be word aligned and a3, a3, 3 beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + PTR_SUBU a2, a2, a3 # subtract from remaining count LWHI v1, 0(a0) # get next 4 bytes (unaligned) LWLO v1, 3(a0) - addu a0, a0, a3 + PTR_ADDU a0, a0, a3 SWHI v1, 0(a1) # store 1, 2, or 3 bytes to align a1 - addu a1, a1, a3 + PTR_ADDU a1, a1, a3 1: and v1, a2, 3 # compute number of words left - subu a3, a2, v1 + PTR_SUBU a3, a2, v1 move a2, v1 - addu a3, a3, a0 # compute ending address + PTR_ADDU a3, a3, a0 # compute ending address 2: LWHI v1, 0(a0) # copy words a0 unaligned, a1 aligned LWLO v1, 3(a0) - addu a0, a0, 4 + PTR_ADDU a0, a0, 4 sw v1, 0(a1) - addu a1, a1, 4 + PTR_ADDU a1, a1, 4 bne a0, a3, 2b nop # We have to do this mmu-bug. b smallcpy nop aligned: beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + PTR_SUBU a2, a2, a3 # subtract from remaining count LWHI v1, 0(a0) # copy 1, 2, or 3 bytes to align - addu a0, a0, a3 + PTR_ADDU a0, a0, a3 SWHI v1, 0(a1) - addu a1, a1, a3 + PTR_ADDU a1, a1, a3 1: and v1, a2, 3 # compute number of whole words left - subu a3, a2, v1 + PTR_SUBU a3, a2, v1 move a2, v1 - addu a3, a3, a0 # compute ending address + PTR_ADDU a3, a3, a0 # compute ending address 2: lw v1, 0(a0) # copy words - addu a0, a0, 4 + PTR_ADDU a0, a0, 4 sw v1, 0(a1) bne a0, a3, 2b - addu a1, a1, 4 + PTR_ADDU a1, a1, 4 smallcpy: ble a2, zero, 2f - addu a3, a2, a0 # compute ending address + PTR_ADDU a3, a2, a0 # compute ending address 1: lbu v1, 0(a0) # copy bytes - addu a0, a0, 1 + PTR_ADDU a0, a0, 1 sb v1, 0(a1) bne a0, a3, 1b - addu a1, a1, 1 # MMU BUG ? can not do -1(a1) at 0x80000000!! + PTR_ADDU a1, a1, 1 # MMU BUG ? can not do -1(a1) at 0x80000000!! 2: j ra nop diff --git a/sys/lib/libkern/arch/mips64/bzero.S b/sys/lib/libkern/arch/mips64/bzero.S index 9fe50002b24..aa2061b3314 100644 --- a/sys/lib/libkern/arch/mips64/bzero.S +++ b/sys/lib/libkern/arch/mips64/bzero.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bzero.S,v 1.5 2004/09/21 10:42:37 miod Exp $ */ +/* $OpenBSD: bzero.S,v 1.6 2004/10/08 14:42:09 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -42,44 +42,44 @@ ALEAF(blkclr) .set noreorder #ifdef _STANDALONE blt a1, 12, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address + PTR_SUBU a3, zero, a0 # compute # bytes to word align address and a3, a3, 3 beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count + PTR_SUBU a1, a1, a3 # subtract from remaining count SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 + PTR_ADDU a0, a0, a3 1: and v0, a1, 3 # compute number of words left - subu a3, a1, v0 + PTR_SUBU a3, a1, v0 move a1, v0 - addu a3, a3, a0 # compute ending address + PTR_ADDU a3, a3, a0 # compute ending address 2: - addu a0, a0, 4 # clear words + PTR_ADDU a0, a0, 4 # clear words bne a0, a3, 2b # unrolling loop does not help sw zero, -4(a0) # since we are limited by memory speed #else blt a1, 24, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address + PTR_SUBU a3, zero, a0 # compute # bytes to word align address and a3, a3, 7 beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count + PTR_SUBU a1, a1, a3 # subtract from remaining count SDHI zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 + PTR_ADDU a0, a0, a3 1: and v0, a1, 7 # compute number of words left - subu a3, a1, v0 + PTR_SUBU a3, a1, v0 move a1, v0 - addu a3, a3, a0 # compute ending address + PTR_ADDU a3, a3, a0 # compute ending address 2: - addu a0, a0, 8 # clear words + PTR_ADDU a0, a0, 8 # clear words bne a0, a3, 2b # unrolling loop does not help sd zero, -8(a0) # since we are limited by memory speed #endif smallclr: ble a1, zero, 2f - addu a3, a1, a0 # compute ending address + PTR_ADDU a3, a1, a0 # compute ending address 1: - addu a0, a0, 1 # clear bytes + PTR_ADDU a0, a0, 1 # clear bytes bne a0, a3, 1b sb zero, -1(a0) 2: diff --git a/sys/lib/libkern/arch/mips64/strcmp.S b/sys/lib/libkern/arch/mips64/strcmp.S index b45df70697b..430efad02b6 100644 --- a/sys/lib/libkern/arch/mips64/strcmp.S +++ b/sys/lib/libkern/arch/mips64/strcmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strcmp.S,v 1.3 2004/09/09 15:41:18 pefo Exp $ */ +/* $OpenBSD: strcmp.S,v 1.4 2004/10/08 14:42:09 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -49,13 +49,13 @@ LEAF(strcmp, 0) lbu t0, 1(a0) # unroll loop lbu t1, 1(a1) beq t0, zero, LessOrEq # end of first string? - addu a0, a0, 2 + PTR_ADDU a0, a0, 2 beq t0, t1, 1b - addu a1, a1, 2 + PTR_ADDU a1, a1, 2 NotEq: j ra - subu v0, t0, t1 + PTR_SUBU v0, t0, t1 LessOrEq: j ra - subu v0, zero, t1 + PTR_SUBU v0, zero, t1 END(strcmp) diff --git a/sys/lib/libkern/arch/mips64/strlen.S b/sys/lib/libkern/arch/mips64/strlen.S index 214f88eddd5..1fd6681c2ee 100644 --- a/sys/lib/libkern/arch/mips64/strlen.S +++ b/sys/lib/libkern/arch/mips64/strlen.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strlen.S,v 1.3 2004/09/09 15:41:18 pefo Exp $ */ +/* $OpenBSD: strlen.S,v 1.4 2004/10/08 14:42:09 pefo Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -38,12 +38,12 @@ */ LEAF(strlen, 0) .set noreorder - addu v1, a0, 1 + PTR_ADDU v1, a0, 1 1: lb v0, 0(a0) # get byte from string - addu a0, a0, 1 # increment pointer + PTR_ADDU a0, a0, 1 # increment pointer bne v0, zero, 1b # continue if not end nop j ra - subu v0, a0, v1 # compute length - 1 for '\0' char + PTR_SUBU v0, a0, v1 # compute length - 1 for '\0' char END(strlen) |