1dd11460aSIngo Weinhold/*
2dd11460aSIngo Weinhold * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
3dd11460aSIngo Weinhold * Distributed under the terms of the MIT License.
4dd11460aSIngo Weinhold */
5dd11460aSIngo Weinhold#ifndef _KERNEL_DEBUG_HEX_DUMP_H
6dd11460aSIngo Weinhold#define _KERNEL_DEBUG_HEX_DUMP_H
7dd11460aSIngo Weinhold
8dd11460aSIngo Weinhold
9dd11460aSIngo Weinhold#include <debug.h>
10dd11460aSIngo Weinhold
11dd11460aSIngo Weinhold
12dd11460aSIngo Weinholdnamespace BKernel {
13dd11460aSIngo Weinhold
14dd11460aSIngo Weinhold
15dd11460aSIngo Weinholdenum {
16dd11460aSIngo Weinhold	HEX_DUMP_FLAG_OMIT_ADDRESS	= 0x01
17dd11460aSIngo Weinhold};
18dd11460aSIngo Weinhold
19dd11460aSIngo Weinhold
20dd11460aSIngo Weinholdclass HexDumpDataProvider {
21dd11460aSIngo Weinholdpublic:
22dd11460aSIngo Weinhold	virtual						~HexDumpDataProvider();
23dd11460aSIngo Weinhold
24dd11460aSIngo Weinhold	virtual	bool				HasMoreData() const = 0;
25dd11460aSIngo Weinhold	virtual	uint8				NextByte() = 0;
26dd11460aSIngo Weinhold	virtual	bool				GetAddressString(char* buffer,
27dd11460aSIngo Weinhold									size_t bufferSize) const;
28dd11460aSIngo Weinhold};
29dd11460aSIngo Weinhold
30dd11460aSIngo Weinhold
31dd11460aSIngo Weinholdclass HexDumpBufferDataProvider : public HexDumpDataProvider {
32dd11460aSIngo Weinholdpublic:
33dd11460aSIngo Weinhold								HexDumpBufferDataProvider(const void* data,
34dd11460aSIngo Weinhold									size_t dataSize);
35dd11460aSIngo Weinhold
36dd11460aSIngo Weinhold	virtual	bool				HasMoreData() const;
37dd11460aSIngo Weinhold	virtual	uint8				NextByte();
38dd11460aSIngo Weinhold	virtual	bool				GetAddressString(char* buffer,
39dd11460aSIngo Weinhold									size_t bufferSize) const;
40dd11460aSIngo Weinhold
41dd11460aSIngo Weinholdprivate:
42dd11460aSIngo Weinhold			const uint8*		fData;
43dd11460aSIngo Weinhold			size_t				fDataSize;
44dd11460aSIngo Weinhold};
45dd11460aSIngo Weinhold
46dd11460aSIngo Weinhold
47dd11460aSIngo Weinholdvoid	print_hex_dump(HexDumpDataProvider& data, size_t maxBytes,
48dd11460aSIngo Weinhold			uint32 flags = 0);
49dd11460aSIngo Weinholdvoid	print_hex_dump(const void* data, size_t maxBytes, uint32 flags = 0);
50dd11460aSIngo Weinhold
51dd11460aSIngo Weinhold
52dd11460aSIngo Weinhold}	// namespace BKernel
53dd11460aSIngo Weinhold
54dd11460aSIngo Weinhold
55dd11460aSIngo Weinhold#endif	/* _KERNEL_DEBUG_HEX_DUMP_H */
56