public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: "Andreas Kleen" <ak@suse.de>
Cc: <linux-kernel@vger.kernel.org>, <discuss@x86-64.org>
Subject: [PATCH 28/39] NLKD/x86-64 - run time library
Date: Wed, 09 Nov 2005 15:23:50 +0100	[thread overview]
Message-ID: <43721485.76F0.0078.0@novell.com> (raw)
In-Reply-To: 43721459.76F0.0078.0@novell.com

[-- Attachment #1: Type: text/plain, Size: 140 bytes --]

x86_64-specific implementation of the support routines of NLKD.

Signed-Off-By: Jan Beulich <jbeulich@novell.com>

(actual patch attached)


[-- Attachment #2: nlkd-rtl-x86_64.patch --]
[-- Type: application/octet-stream, Size: 8333 bytes --]

x86_64-specific implementation of the support routines of NLKD.

Signed-Off-By: Jan Beulich <jbeulich@novell.com>

Index: 2.6.14-nlkd/debug/nlkd/dbgAMD64.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ 2.6.14-nlkd/debug/nlkd/dbgAMD64.S	2005-10-05 11:37:21.000000000 +0200
@@ -0,0 +1,403 @@
+/*****************************************************************************
+ *
+ *   File Name:      dbgAMD64.S
+ *   Created by:     jbeulich
+ *   %version:       8 %
+ *   %derived_by:    jbeulich %
+ *   %date_modified: Wed Oct 05 01:08:52 2005 %
+ *
+ ****************************************************************************/
+/*****************************************************************************
+ *                                                                           *
+ * Copyright (c) 2002-2005 Novell, Inc. All Rights Reserved.                 *
+ *                                                                           *
+ * This program is free software; you can redistribute it and/or             *
+ * modify it under the terms of version 2 of the GNU General Public License  *
+ * as published by the Free Software Foundation.                             *
+ *                                                                           *
+ * This program is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              *
+ * GNU General Public License for more details.                              *
+ *                                                                           *
+ * You should have received a copy of the GNU General Public License         *
+ * along with this program; if not, contact Novell, Inc.                     *
+ *                                                                           *
+ * To contact Novell about this file by physical or electronic mail,         *
+ * you may find current contact information at www.novell.com.               *
+ *                                                                           *
+ *****************************************************************************/
+/*****************************************************************************
+ *
+ *	 File Description:
+ *
+ ****************************************************************************/
+
+#include <linux/config.h>
+.equiv PROCEDURE_ALIGN, 1
+#include "asm-amd64.h"
+
+// int dbgCompareMem(const void*, const void*, size_t);
+.pubproc dbgCompareMem
+	mov	rcx, rdx
+	xchg	rsi, rdi
+	xor	eax, eax
+	xor	edx, edx
+	repe cmpsb
+	seta	al
+	setb	dl
+	sub	eax, edx
+	ret
+.endp dbgCompareMem
+
+// int dbgCompareStr(const char*, const char*);
+.pubproc dbgCompareStr
+	xor	eax, eax
+0:
+	mov	al, [rdi]
+	inc	rdi
+	test	al, al
+	jz	1f
+	cmp	al, [rsi]
+	jne	1f
+	inc	rsi
+	jmp	0b
+1:
+	movzx	edx, byte ptr [rsi]
+	sub	eax, edx
+	ret
+.endp dbgCompareStr
+
+// void*dbgCopyMem(void*, const void*, size_t);
+// Note: The minimum requirements to this routine are that copying between properly
+//       aligned buffers with a suitable size will be carried out with the maximum
+//       access granularity possible.
+.pubproc dbgCopyMem
+	mov	rcx, rdx
+	test	dl, byte
+	mov	rax, rdi
+	jz	0f
+	rep movsb
+	ret
+0:
+	test	dl, word or dword
+	jz	2f
+	shr	rcx, 2
+	jnc	1f
+	adc	rcx, rcx
+	.byte	0x66
+1:
+	rep movsd
+	ret
+2:
+	shr	rcx, 3
+	rep movsq
+	ret
+.endp dbgCopyMem
+
+// char*dbgCopyStr(char*, const char*);
+.pubproc dbgCopyStr
+	mov	rax, rdi
+0:
+	cmp	byte ptr [rsi], 0
+	movsb
+	jne	0b
+	ret
+.endp dbgCopyStr
+
+// char*dbgCopyStrP(char*, const char*);
+.pubproc dbgCopyStrP
+0:
+	lodsb
+	stosb
+	test	al, al
+	jnz	0b
+	lea	rax, [rdi-byte]
+	ret
+.endp dbgCopyStrP
+
+// unsigned dbgCountBits(uint64_t);
+.pubproc dbgCountBits
+	shld	rsi, rdi, 32
+	xor	eax, eax
+0:
+	shr	edi, 1
+	adc	eax, 0
+	shr	esi, 1
+	adc	eax, 0
+	test	edi, edi
+	jnz	0b
+	test	esi, esi
+	jnz	0b
+	ret
+.endp dbgCountBits
+
+// size_t dbgCountStr(const char*);
+.pubproc dbgCountStr
+	or	rcx, not 0
+	xor	eax, eax
+	repne scasb
+	add	rcx, 2
+	sub	rax, rcx
+	ret
+.endp dbgCountStr
+
+// size_t dbgCountWstr(const wchar_t*);
+.pubproc dbgCountWstr
+	or	rcx, not 0
+	xor	eax, eax
+	repne scasw
+	add	rcx, 2
+	sub	rax, rcx
+	ret
+.endp dbgCountWstr
+
+// char*dbgFindChar(const char*, char);
+.pubproc dbgFindChar
+0:
+	mov	dl, [rdi]
+	cmp	sil, dl
+	je	1f
+	inc	rdi
+	test	dl, dl
+	jnz	0b
+	xor	eax, eax
+	ret
+1:
+	mov	rax, rdi
+	ret
+.endp dbgFindChar
+
+// wchar_t*dbgFindWchar(const wchar_t*, wchar_t);
+.pubproc dbgFindWchar
+0:
+	mov	dx, [rdi]
+	cmp	si, dx
+	je	1f
+	add	rdi, word
+	test	dx, dx
+	jnz	0b
+	xor	eax, eax
+	ret
+1:
+	mov	rax, rdi
+	ret
+.endp dbgFindWchar
+
+// char*dbgWstr2Str(char*, const wchar_t*);
+.pubproc dbgWstr2Str
+	mov	rax, rdi
+	mov	cl, '?'
+0:
+	movzx	edx, word ptr [rsi]
+	add	rsi, word
+	cmp	edx, 0x7f
+	cmova	edx, ecx
+	mov	[rdi], dl
+	inc	rdi
+	test	edx, edx
+	jnz	0b
+	ret
+.endp dbgWstr2Str
+
+// int dbgLower(int);
+.pubproc dbgLower
+	mov	eax, edi
+	cmp	edi, 'A'
+	jb	0f
+	cmp	edi, 'Z'
+	ja	0f
+	add	al, 'a' - 'A'
+0:
+	ret
+.endp dbgLower
+
+// int dbgUpper(int);
+.pubproc dbgUpper
+	mov	eax, edi
+	cmp	edi, 'a'
+	jb	0f
+	cmp	edi, 'z'
+	ja	0f
+	add	al, 'A' - 'a'
+0:
+	ret
+.endp dbgUpper
+
+// void*dbgFillMem(void*, int, size_t);
+.pubproc dbgFillMem
+	mov	rcx, rdx
+	mov	eax, esi
+	jmp	0f
+// void*dbgZeroMem(void*, size_t);
+.pubentry dbgZeroMem
+	mov	ecx, esi
+	xor	eax, eax
+0:
+	mov	rdx, rdi
+	rep stosb
+	mov	rax, rdx
+	ret
+.endp dbgFillMem
+
+// uint8_t*dbgFindInt8(const uint8_t*, uint8_t, size_t);
+// void*dbgFindByte(const void*, int, size_t);
+.pubproc dbgFindInt8
+.pubentry dbgFindByte
+	mov	rcx, rdx
+	jrcxz	0f
+	mov	eax, esi
+	repne scasb
+	lea	rax, [rdi-byte]
+	je	1f
+0:
+	xor	eax, eax
+1:
+	ret
+.endp dbgFindInt8
+
+// uint16_t*dbgFindInt16(const uint16_t*, uint16_t, size_t);
+.pubproc dbgFindInt16
+	mov	rcx, rdx
+	jrcxz	0f
+	mov	eax, esi
+	repne scasw
+	lea	rax, [rdi-word]
+	je	1f
+0:
+	xor	eax, eax
+1:
+	ret
+.endp dbgFindInt16
+
+// uint32_t*dbgFindInt32(const uint32_t*, uint32_t, size_t);
+// nuint_t*dbgFindIntN(const nuint_t*, nuint_t, size_t);
+.pubproc dbgFindInt32
+.pubentry dbgFindIntN
+	mov	rcx, rdx
+	jrcxz	0f
+	mov	eax, esi
+	repne scasd
+	lea	rax, [rdi-dword]
+	je	1f
+0:
+	xor	eax, eax
+1:
+	ret
+.endp dbgFindInt32
+
+// uint64_t*dbgFindInt64(const uint64_t*, uint64_t, size_t);
+// void**dbgFindPtr(const void**, const void*, size_t);
+.pubproc dbgFindInt64
+.pubentry dbgFindPtr
+	mov	rcx, rdx
+	jrcxz	0f
+	mov	rax, rsi
+	repne scasq
+	lea	rax, [rdi-qword]
+	je	1f
+0:
+	xor	eax, eax
+1:
+	ret
+.endp dbgFindInt64
+
+// uint64_t dbgMultiply(uint64_t, uint64_t, uint64_t*overflow);
+.pubproc dbgMultiply
+	mov	rax, rdi
+	mov	rcx, rdx
+	mul	rsi
+	mov	[rcx], rdx
+	ret
+.endp dbgMultiply
+
+// nint_t dbgLog2(uint64_t)
+.pubproc dbgLog2
+	bsr	rax, rdi
+	jnz	0f
+	or	eax, not 0
+0:
+	ret
+.endp dbgLog2
+
+// uint8_t dbgRotl8(uint8_t, nuint_t);
+.pubproc dbgRotl8
+	mov	eax, edi
+	mov	ecx, esi
+	rol	al, cl
+	ret
+.endp dbgRotl8
+
+// uint8_t dbgRotr8(uint8_t, nuint_t);
+.pubproc dbgRotr8
+	mov	eax, edi
+	mov	ecx, esi
+	ror	al, cl
+	ret
+.endp dbgRotr8
+
+// uint16_t dbgRotl16(uint16_t, nuint_t);
+.pubproc dbgRotl16
+	mov	eax, edi
+	mov	ecx, esi
+	rol	ax, cl
+	ret
+.endp dbgRotl16
+
+// uint16_t dbgRotr16(uint16_t, nuint_t);
+.pubproc dbgRotr16
+	mov	eax, edi
+	mov	ecx, esi
+	ror	ax, cl
+	ret
+.endp dbgRotr16
+
+// uint32_t dbgRotl32(uint32_t, nuint_t);
+.pubproc dbgRotl32
+	mov	eax, edi
+	mov	ecx, esi
+	rol	eax, cl
+	ret
+.endp dbgRotl32
+
+// uint32_t dbgRotr32(uint32_t, nuint_t);
+.pubproc dbgRotr32
+	mov	eax, edi
+	mov	ecx, esi
+	ror	eax, cl
+	ret
+.endp dbgRotr32
+
+// uint64_t dbgRotl64(uint64_t, nuint_t);
+.pubproc dbgRotl64
+	mov	rax, rdi
+	mov	ecx, esi
+	rol	rax, cl
+	ret
+.endp dbgRotl64
+
+// uint64_t dbgRotr64(uint64_t, nuint_t);
+.pubproc dbgRotr64
+	mov	rax, rdi
+	mov	ecx, esi
+	ror	rax, cl
+	ret
+.endp dbgRotr64
+
+.pubproc dbgDivideU
+	mov	eax, edi
+	xor	edx, edx
+	div	esi
+	shl	rdx, 32
+	or	rax, rdx
+	ret
+.endp dbgDivideU
+
+.pubproc dbgDivideS
+	mov	eax, edi
+	cdq
+	idiv	esi
+	shl	rdx, 32
+	or	rax, rdx
+	ret
+.endp dbgDivideS

  reply	other threads:[~2005-11-09 14:22 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-09 13:54 [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jan Beulich
2005-11-09 13:56 ` [PATCH 1/39] NLKD - an alternative kallsyms approach Jan Beulich
2005-11-09 13:57   ` [PATCH 2/39] NLKD - an alternative early ioremap approach Jan Beulich
2005-11-09 13:58     ` [PATCH 3/39] NLKD - early/late CPU up/down notification Jan Beulich
2005-11-09 13:59       ` [PATCH 4/39] NLKD/i386 " Jan Beulich
2005-11-09 14:01       ` [PATCH 5/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:10         ` Andi Kleen
2005-11-14  8:04           ` [discuss] " Jan Beulich
2005-11-14 12:37             ` Andi Kleen
2005-11-09 14:01       ` [PATCH 6/39] NLKD - early panic notification Jan Beulich
2005-11-09 14:02         ` [PATCH 7/39] NLKD - task create/destroy notification Jan Beulich
2005-11-09 14:03           ` [PATCH 8/39] NLKD - rmmod notification Jan Beulich
2005-11-09 14:04             ` [PATCH 9/39] NLKD - hotkey notification Jan Beulich
2005-11-09 14:05               ` [PATCH 10/39] NLKD - console layout change notification Jan Beulich
2005-11-09 14:06                 ` [PATCH 11/39] NLKD - time adjustment Jan Beulich
2005-11-09 14:06                   ` [PATCH 12/39] NLKD/i386 " Jan Beulich
2005-11-09 19:10                     ` George Anzinger
2005-11-10  8:12                       ` Jan Beulich
2005-11-11  0:17                         ` George Anzinger
2005-11-09 14:08                   ` [PATCH 13/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:13                     ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Jan Beulich
2005-11-09 14:14                       ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Jan Beulich
2005-11-09 14:15                         ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Jan Beulich
2005-11-09 14:16                           ` [PATCH 21/39] NLKD/x86-64 - core adjustments Jan Beulich
2005-11-10 13:24                           ` [PATCH 20/39] NLKD/x86-64 - switch_to() floating point adjustment Andi Kleen
2005-11-10 14:07                             ` Jan Beulich
2005-11-10 13:23                         ` [PATCH 19/39] NLKD/x86-64 - stack-pointer-invalid markers Andi Kleen
2005-11-10 14:25                           ` Jan Beulich
2005-11-10 13:21                       ` [PATCH 18/39] NLKD/x86-64 - INT1/INT3 handling changes Andi Kleen
2005-11-10 14:07                         ` Jan Beulich
2005-11-10 14:25                           ` Andi Kleen
2005-11-10 15:00                             ` Jan Beulich
2005-11-11  3:39                               ` [discuss] " Andi Kleen
2005-11-10 13:19                     ` [PATCH 13/39] NLKD/x86-64 - time adjustment Andi Kleen
2005-11-10 14:23                       ` Jan Beulich
2005-11-11  2:12                         ` Andi Kleen
2005-11-12  9:22                           ` Vojtech Pavlik
2005-11-12 17:21                             ` Andi Kleen
2005-11-12 20:44                               ` Vojtech Pavlik
2005-11-15  0:38                                 ` George Anzinger
2005-11-15  1:05                                   ` [discuss] " Andi Kleen
2005-11-15  7:50                                     ` Vojtech Pavlik
2005-11-15  8:24                                       ` Jan Beulich
2005-11-10 14:43                       ` Vojtech Pavlik
2005-11-09 14:09                   ` [PATCH 14/39] NLKD - kernel trace buffer access Jan Beulich
2005-11-09 14:09                     ` [PATCH 15/39] NLKD - early pseudo-fs Jan Beulich
2005-11-09 14:11                       ` [PATCH 16/39] NLKD - core adjustments Jan Beulich
2005-11-09 14:11                         ` [PATCH 17/39] NLKD/i386 " Jan Beulich
2005-11-09 19:00                           ` Adrian Bunk
2005-11-10  8:04                             ` Jan Beulich
2005-11-10 10:29                               ` Adrian Bunk
2005-11-10 11:52                                 ` Jan Beulich
2005-11-10 12:36                                   ` Lars Marowsky-Bree
2005-11-09 14:18                         ` [PATCH 22/39] NLKD - core Jan Beulich
2005-11-09 14:19                           ` [PATCH 23/39] NLKD/x86 " Jan Beulich
2005-11-09 14:20                             ` [PATCH 24/39] NLKD/i386 " Jan Beulich
2005-11-09 14:21                             ` [PATCH 25/39] NLKD/x86-64 " Jan Beulich
2005-11-10 13:30                               ` Andi Kleen
2005-11-09 14:22                           ` [PATCH 26/39] NLKD - run time library Jan Beulich
2005-11-09 14:23                             ` [PATCH 27/39] NLKD/i386 " Jan Beulich
2005-11-09 14:23                               ` Jan Beulich [this message]
2005-11-10 13:32                                 ` [PATCH 28/39] NLKD/x86-64 " Andi Kleen
     [not found]                             ` <437214B7.76F0.0078.0@novell.com>
     [not found]                               ` <4372156A.76F0.0078.0@novell.com>
2005-11-09 14:28                                 ` [PATCH 34/39] NLKD/x86 - Console Debug Agent Jan Beulich
     [not found]                                 ` <43721600.76F0.0078.0@novell.com>
2005-11-09 14:30                                   ` [PATCH 38/39] NLKD/i386 - Remote " Jan Beulich
2005-11-09 14:31                                   ` [PATCH 39/39] NLKD/x86-64 " Jan Beulich
2005-11-09 14:29                       ` [PATCH 15/39] NLKD - early pseudo-fs Al Viro
2005-11-09 14:37                         ` Jan Beulich
2005-11-09 15:00                           ` Al Viro
2005-11-09 16:00                             ` Jan Beulich
2005-11-10  5:44                     ` [PATCH 14/39] NLKD - kernel trace buffer access Keith Owens
2005-11-10  8:02                       ` Jan Beulich
2005-11-09 18:51                   ` [PATCH 11/39] NLKD - time adjustment George Anzinger
2005-11-09 16:50         ` [PATCH 6/39] NLKD - early panic notification Greg KH
2005-11-09 16:45       ` [PATCH 3/39] NLKD - early/late CPU up/down notification Greg KH
2005-11-09 17:09         ` Jan Beulich
2005-11-09 17:19           ` Greg KH
2005-11-10  7:41             ` Jan Beulich
2005-11-10 20:59               ` Sam Ravnborg
2005-11-11  7:52                 ` Jan Beulich
2005-11-12 20:52                   ` Randy.Dunlap
2005-11-10 23:01               ` Greg KH
2005-11-11 10:06     ` [PATCH 2/39] NLKD - an alternative early ioremap approach Pavel Machek
2005-11-11 10:19       ` Jan Beulich
2005-11-09 16:50   ` [PATCH 1/39] NLKD - an alternative kallsyms approach Randy.Dunlap
2005-11-09 16:57     ` Greg KH
2005-11-09 17:20     ` Jan Beulich
2005-11-09 16:59 ` [PATCH 0/39] NLKD - Novell Linux Kernel Debugger Jeff Garzik
2005-11-09 17:06   ` Randy.Dunlap
2005-11-09 17:14     ` Jan Beulich
2005-11-09 17:56       ` Alan Cox
2005-11-09 18:05       ` Greg KH
2005-11-09 18:54       ` Paul Jackson
2005-11-10 12:41       ` Christoph Hellwig
2005-11-13  1:09     ` Andi Kleen
2005-11-13  2:53       ` jmerkey
2005-11-13  3:44         ` Andi Kleen
2005-11-13  3:26           ` Jeff V. Merkey
2005-11-13  3:32             ` Jeff V. Merkey
2005-11-09 17:53   ` Alan Cox
2005-11-09 16:25     ` Jeffrey V. Merkey
2005-11-10 14:48     ` Mark Lord
2005-11-10 15:28       ` Tom Rini
2005-11-10 16:37       ` Alan Cox
2005-11-13  1:11       ` Andi Kleen
     [not found] ` <437214E4.76F0.0078.0@novell.com>
     [not found]   ` <4372153C.76F0.0078.0@novell.com>
2005-11-10 13:33     ` [PATCH 32/39] NLKD/x86-64 - Core Debug Engine Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43721485.76F0.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox