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