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

#include "cellUtilSpurs.h"
#include "cellUtilSpursTaskset.h"

__CELL_UTIL_SPURS_BEGIN

int Taskset::create(
	Taskset* taskset,
	const char* name,
	Spurs* spurs,
	uint64_t argument,
	const uint8_t priority[CELL_SPURS_MAX_SPU],
	unsigned max)
{
	CellSpursTasksetAttribute attr;
	__RETURN_IF(cellSpursTasksetAttributeInitialize(&attr, argument, priority, max));
	__RETURN_IF(cellSpursTasksetAttributeSetName(&attr, name));
	__RETURN_IF(cellSpursTasksetAttributeSetTasksetSize(&attr, CELL_SPURS_TASKSET_CLASS1_SIZE));
	__RETURN_IF(cellSpursCreateTasksetWithAttribute(spurs, taskset, &attr));
	return CELL_OK;
}

int Taskset::create(
	Taskset* taskset,
	const char* name,
	Spurs* spurs,
	uint64_t argument,
	uint8_t priority_,
	uint8_t mask)
{
	uint8_t priority[CELL_SPURS_MAX_SPU];
	unsigned max = 0;

	for (uint32_t spu = 0; spu < CELL_SPURS_MAX_SPU; ++spu) {
		priority[spu] = (mask & 1) ? priority_ : 0;
		max += mask & 1;
		mask >>= 1;
	}

	return create(taskset, name, spurs, argument, priority, max);
}

__CELL_UTIL_SPURS_END

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