// SCE CONFIDENTIAL
// PLAYSTATION(R)3 Programmer Tool Runtime Library 250.001
// Copyright (C) 2007 Sony Computer Entertainment Inc.
// All Rights Reserved.

#ifndef __CELL_UTIL_SPURS_ELF_H__
#define __CELL_UTIL_SPURS_ELF_H__ 1

#include <cellUtilSpursDefine.h>
#include <stdint.h>
#include <cell/spurs/task.h>

__CELL_UTIL_SPURS_BEGIN

class TaskElf {
	uint64_t m_upper;
	uint64_t m_lower;
	const void* m_elf;
public:
	TaskElf(const void* _elf)
		: m_upper(0), m_lower(0), m_elf(_elf) {}

	const void* elf() const
		{
			return m_elf;
		}

	const CellSpursTaskLsPattern* lsPattern() const
		{
			return (const CellSpursTaskLsPattern*)this;
		}

	unsigned saveBufferSize() const;
	static unsigned saveBufferAlign()
		{
			return CELL_SPURS_TASK_CONTEXT_ALIGN;
		}

	void setRange(unsigned start, unsigned size);
	void unsetRange(unsigned start, unsigned size);
	void unsetReadOnlySegment();
	void setWritableSegment();
	void setStack(unsigned stackSize)
		{
			setRange(CELL_SPURS_TASK_BOTTOM - stackSize, stackSize);
		}
	void unsetAll()
		{
			m_upper = m_lower = 0ull;
		}
	void setAll()
		{
			m_upper = (uint64_t)CELL_SPURS_TASK_TOP_MASK << 32 | 0xffffffffull;
			m_lower = 0xffffffffffffffffull;
		}
};

__CELL_UTIL_SPURS_END

#endif // __CELL_UTIL_SPURS_ELF_H__

// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// tab-width: 4
// End:
// vim:sw=4:sts=4:ts=4
