<commit_before>#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_io.hpp>

#include <util/Logger.h>
#include <util/helpers.hpp>
#include <gui/OpenGl.h>
#include <gui/ContextSettings.h>
#include <gui/Keys.h>
#include "Window.h"

using std::cout;
using std::endl;
using namespace boost::gil;

using namespace logger;

namespace gui {

LogChannel winlog("winlog", "[Window] ");

Window::Window(
		string caption,
		const WindowMode& mode) :
	WindowType(caption, mode),
	_region(0, 0, mode.size.x, mode.size.y),
	_resolution(mode.size.x, mode.size.y),
	_saveFrameRequest(false),
	_frameNumber(0),
	_frameBuffer(0),
	_clear_r(0.5),
	_clear_g(0.5),
	_clear_b(0.5) {

	registerInput(_painter, "painter");

	// register backward signals
	_painter.registerBackwardSlot(_resize);
	_painter.registerBackwardSlot(_keyDown);
	_painter.registerBackwardSlot(_keyUp);
	_painter.registerBackwardSlot(_mouseMove);
	_painter.registerBackwardSlot(_mouseDown);
	_painter.registerBackwardSlot(_mouseUp);

	// register backward callbacks
	_painter.registerBackwardCallback(&Window::onInputAdded, this);
	_painter.registerBackwardCallback(&Window::onModified, this);
	_painter.registerBackwardCallback(&Window::onSizeChanged, this);

	// initiate first redraw
	setDirty();
}

Window::~Window() {

	LOG_DEBUG(winlog) << "[" << getCaption() << "] destructing..." << endl;

	deleteFrameBuffer();

	LOG_DEBUG(winlog) << "[" << getCaption() << "] destructed" << endl;
}

void
Window::createFrameBuffer() {

	deleteFrameBuffer();

	_frameBuffer = new unsigned char[(int)_resolution.x*(int)_resolution.y*3];
}

void
Window::deleteFrameBuffer() {

	if (_frameBuffer) {

		delete[] _frameBuffer;
		_frameBuffer = 0;
	}
}

void
Window::configureViewport() {

	// we want to draw everywhere
	glViewport(0, 0, _resolution.x, _resolution.y);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	// OpenGl units = pixels
	glOrtho(0, _resolution.x, _resolution.y, 0, -1000, 1000); // x left, x right, y bottom, y top, z min, z max

	glMatrixMode(GL_MODELVIEW);

	LOG_ALL(winlog) << "[" << getCaption() << "] set drawing area to "
	                << "(0, 0, " << _resolution.x << ", " << _resolution.y << ")"
	                << std::endl;

	GL_ASSERT;
}

const point<double>&
Window::getResolution() {

	return _resolution;
}

void
Window::processResizeEvent(int width, int height) {

	_region.maxX = width;
	_region.maxY = height;
	_resolution.x = width;
	_resolution.y = height;

	{
		// ensure that our context is active
		OpenGl::Guard guard(this);

		configureViewport();
		createFrameBuffer();
	}
}

void
Window::processKeyUpEvent(const keys::Key& key, const Modifiers& modifiers) {

	KeyUp signal(key, modifiers);
	_keyUp(signal);
}

void
Window::processKeyDownEvent(const keys::Key& key, const Modifiers& modifiers) {

	KeyDown signal(key, modifiers);
	_keyDown(signal);
}

bool
Window::processButtonUpEvent(
		const buttons::Button&     button,
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	MouseUp signal(button, position, modifiers);
	_mouseUp(signal);
}

bool
Window::processButtonDownEvent(
		const buttons::Button&     button,
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	LOG_ALL(winlog) << "[Window (" << getCaption() << ")] "
	                << "a mouse button was pressed" << std::endl;

	MouseDown signal(button, position, modifiers);
	_mouseDown(signal);
}

bool
Window::processMouseMoveEvent(
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	MouseMove signal(position, modifiers);
	_mouseMove(signal);
}

GlContext*
Window::createGlContext() {

	LOG_ALL(winlog) << "[" << getCaption() << "] creating a new GlContext" << std::endl;

	GlContext* globalContext = OpenGl::getGlobalContext();
	globalContext->activate();

	ContextSettings settings;

	// create the context
	GlContext* glContext = new GlContext(this, settings, globalContext);

	// activate it
	glContext->activate();

	configureViewport();

	// return it
	return glContext;
}

void
Window::redraw() {

	// They say OpenGl is thread safe. They are wrong.
	boost::mutex::scoped_lock lock(OpenGl::getMutex());

	// prepare painters
	_resize(_region);

	// ensure that our context is active
	OpenGl::Guard guard(this);

	clear();

	LOG_ALL(winlog) << "[" << getCaption() << "] redrawing my content" << endl;

	if (_painter) {

		// make sure the painter is up-to-date
		updateInputs();

		// draw the updated painter
		_painter->draw(_region, point<double>(1.0, 1.0));

	} else {

		LOG_ALL(winlog) << "[" << getCaption() << "] no content so far..." << endl;
	}

	GL_ASSERT;

	flush();

	GL_ASSERT;
}

void
Window::clear() {

	glClearColor(_clear_r, _clear_g, _clear_b, 0.0);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	GL_ASSERT;
}

void
Window::flush() {

	OpenGl::flush();
}

void
Window::requestFrameSave() {

	_saveFrameRequest = true;
}

void
Window::saveFrame() {

	if (closed())
		return;

	// ensure that our context is active
	OpenGl::Guard guard(this);

	glReadPixels(
			0, 0,
			_resolution.x, _resolution.y,
			GL_RGB, GL_UNSIGNED_BYTE,
			_frameBuffer);
	GL_ASSERT;

	rgb8c_view_t frameView =
			interleaved_view(
					_resolution.x, _resolution.y,
					(const rgb8_pixel_t*)_frameBuffer,
					_resolution.x*3);

	png_write_view(
			"./shots/" + getCaption() + to_string_with_leading_zeros(_frameNumber, 8) + ".png",
			flipped_up_down_view(frameView));

	_frameNumber++;
}

void
Window::onInputAdded(const pipeline::InputAdded<gui::Painter>& signal) {

	setDirty();
}

void
Window::onModified(const pipeline::Modified& signal) {

	setDirty();
}

void
Window::onSizeChanged(const SizeChanged& signal) {

	// TODO:
	// Here, we could resize the window to fit the view. However, this should be
	// an optional feature.

	setDirty();
}

void
Window::processCloseEvent(){

	LOG_DEBUG(winlog) << "[" << getCaption() << "] invalidating my GlContext" << endl;

	// ensure that our context is destructed
	OpenGl::Guard guard(0);

	LOG_DEBUG(winlog) << "[" << getCaption() << "] closing window now" << endl;

	close();
}

} // namespace gui
<commit_msg>made Window send Resize only when really resized (not for every redraw)<commit_after>#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_io.hpp>

#include <util/Logger.h>
#include <util/helpers.hpp>
#include <gui/OpenGl.h>
#include <gui/ContextSettings.h>
#include <gui/Keys.h>
#include "Window.h"

using std::cout;
using std::endl;
using namespace boost::gil;

using namespace logger;

namespace gui {

LogChannel winlog("winlog", "[Window] ");

Window::Window(
		string caption,
		const WindowMode& mode) :
	WindowType(caption, mode),
	_region(0, 0, mode.size.x, mode.size.y),
	_resolution(mode.size.x, mode.size.y),
	_saveFrameRequest(false),
	_frameNumber(0),
	_frameBuffer(0),
	_clear_r(0.5),
	_clear_g(0.5),
	_clear_b(0.5) {

	registerInput(_painter, "painter");

	// register backward signals
	_painter.registerBackwardSlot(_resize);
	_painter.registerBackwardSlot(_keyDown);
	_painter.registerBackwardSlot(_keyUp);
	_painter.registerBackwardSlot(_mouseMove);
	_painter.registerBackwardSlot(_mouseDown);
	_painter.registerBackwardSlot(_mouseUp);

	// register backward callbacks
	_painter.registerBackwardCallback(&Window::onInputAdded, this);
	_painter.registerBackwardCallback(&Window::onModified, this);
	_painter.registerBackwardCallback(&Window::onSizeChanged, this);

	// initiate first redraw
	setDirty();
}

Window::~Window() {

	LOG_DEBUG(winlog) << "[" << getCaption() << "] destructing..." << endl;

	deleteFrameBuffer();

	LOG_DEBUG(winlog) << "[" << getCaption() << "] destructed" << endl;
}

void
Window::createFrameBuffer() {

	deleteFrameBuffer();

	_frameBuffer = new unsigned char[(int)_resolution.x*(int)_resolution.y*3];
}

void
Window::deleteFrameBuffer() {

	if (_frameBuffer) {

		delete[] _frameBuffer;
		_frameBuffer = 0;
	}
}

void
Window::configureViewport() {

	// we want to draw everywhere
	glViewport(0, 0, _resolution.x, _resolution.y);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	// OpenGl units = pixels
	glOrtho(0, _resolution.x, _resolution.y, 0, -1000, 1000); // x left, x right, y bottom, y top, z min, z max

	glMatrixMode(GL_MODELVIEW);

	LOG_ALL(winlog) << "[" << getCaption() << "] set drawing area to "
	                << "(0, 0, " << _resolution.x << ", " << _resolution.y << ")"
	                << std::endl;

	GL_ASSERT;
}

const point<double>&
Window::getResolution() {

	return _resolution;
}

void
Window::processResizeEvent(int width, int height) {

	_region.maxX = width;
	_region.maxY = height;
	_resolution.x = width;
	_resolution.y = height;

	{
		// ensure that our context is active
		OpenGl::Guard guard(this);

		configureViewport();
		createFrameBuffer();
	}

	// prepare painters
	_resize(_region);
}

void
Window::processKeyUpEvent(const keys::Key& key, const Modifiers& modifiers) {

	KeyUp signal(key, modifiers);
	_keyUp(signal);
}

void
Window::processKeyDownEvent(const keys::Key& key, const Modifiers& modifiers) {

	KeyDown signal(key, modifiers);
	_keyDown(signal);
}

bool
Window::processButtonUpEvent(
		const buttons::Button&     button,
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	MouseUp signal(button, position, modifiers);
	_mouseUp(signal);
}

bool
Window::processButtonDownEvent(
		const buttons::Button&     button,
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	LOG_ALL(winlog) << "[Window (" << getCaption() << ")] "
	                << "a mouse button was pressed" << std::endl;

	MouseDown signal(button, position, modifiers);
	_mouseDown(signal);
}

bool
Window::processMouseMoveEvent(
		const util::point<double>& position,
		const Modifiers&           modifiers) {

	MouseMove signal(position, modifiers);
	_mouseMove(signal);
}

GlContext*
Window::createGlContext() {

	LOG_ALL(winlog) << "[" << getCaption() << "] creating a new GlContext" << std::endl;

	GlContext* globalContext = OpenGl::getGlobalContext();
	globalContext->activate();

	ContextSettings settings;

	// create the context
	GlContext* glContext = new GlContext(this, settings, globalContext);

	// activate it
	glContext->activate();

	configureViewport();

	// return it
	return glContext;
}

void
Window::redraw() {

	// They say OpenGl is thread safe. They are wrong.
	boost::mutex::scoped_lock lock(OpenGl::getMutex());

	// ensure that our context is active
	OpenGl::Guard guard(this);

	clear();

	LOG_ALL(winlog) << "[" << getCaption() << "] redrawing my content" << endl;

	if (_painter) {

		// make sure the painter is up-to-date
		updateInputs();

		// draw the updated painter
		_painter->draw(_region, point<double>(1.0, 1.0));

	} else {

		LOG_ALL(winlog) << "[" << getCaption() << "] no content so far..." << endl;
	}

	GL_ASSERT;

	flush();

	GL_ASSERT;
}

void
Window::clear() {

	glClearColor(_clear_r, _clear_g, _clear_b, 0.0);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	GL_ASSERT;
}

void
Window::flush() {

	OpenGl::flush();
}

void
Window::requestFrameSave() {

	_saveFrameRequest = true;
}

void
Window::saveFrame() {

	if (closed())
		return;

	// ensure that our context is active
	OpenGl::Guard guard(this);

	glReadPixels(
			0, 0,
			_resolution.x, _resolution.y,
			GL_RGB, GL_UNSIGNED_BYTE,
			_frameBuffer);
	GL_ASSERT;

	rgb8c_view_t frameView =
			interleaved_view(
					_resolution.x, _resolution.y,
					(const rgb8_pixel_t*)_frameBuffer,
					_resolution.x*3);

	png_write_view(
			"./shots/" + getCaption() + to_string_with_leading_zeros(_frameNumber, 8) + ".png",
			flipped_up_down_view(frameView));

	_frameNumber++;
}

void
Window::onInputAdded(const pipeline::InputAdded<gui::Painter>& signal) {

	setDirty();
}

void
Window::onModified(const pipeline::Modified& signal) {

	setDirty();
}

void
Window::onSizeChanged(const SizeChanged& signal) {

	// TODO:
	// Here, we could resize the window to fit the view. However, this should be
	// an optional feature.

	setDirty();
}

void
Window::processCloseEvent(){

	LOG_DEBUG(winlog) << "[" << getCaption() << "] invalidating my GlContext" << endl;

	// ensure that our context is destructed
	OpenGl::Guard guard(0);

	LOG_DEBUG(winlog) << "[" << getCaption() << "] closing window now" << endl;

	close();
}

} // namespace gui
<|endoftext|>


<commit_before>#include <isl/set.h>
#include <isl/union_map.h>
#include <isl/union_set.h>
#include <isl/ast_build.h>
#include <isl/schedule.h>
#include <isl/schedule_node.h>

#include <coli/debug.h>
#include <coli/core.h>

#include <String.h>
#include <Halide.h>

int main(int argc, char **argv)
{
	isl_ctx *ctx = isl_ctx_alloc();
	coli::program pgm("program0");
	coli::function fct("function0", &pgm);

	// Declare the computations.  Each computation has:
	// (1) a Halide expression,
	// (2) an isl set representing its iteration space, and
	// (3) is attached to a function.
	coli::computation computation0(ctx, Halide::Expr((uint8_t) 3), "{S0[i,j]: 0<=i<=1000 and 0<=j<=1000}", &fct);
	coli::computation computation1(ctx, Halide::Expr((uint8_t) 5), "{S1[i,j]: 0<=i<=1023 and 0<=j<=1023}", &fct);
	coli::computation computation2(ctx, Halide::Expr((uint8_t) 7), "{S2[i,j]: 0<=i<=1023 and 0<=j<=1023}", &fct);

	// Create a memory buffer (2 dimensional).
	std::vector<int> size1;
	size1.push_back(10);
	size1.push_back(10);
	coli::buffer buf0("buf0", 2, size1, Halide::Int(8), NULL, &fct);

	// Add the buffer as an argument to fct.
	fct.add_argument(buf0);

	// Map the computations to the buffers.
	computation0.SetAccess("{S0[i,j]->buf0[i, j]}");
	computation1.SetAccess("{S1[i,j]->buf0[0, 0]}");
	computation2.SetAccess("{S2[i,j]->buf0[i, j]}");

	// Set the schedule of each computation.
	computation0.Tile(0,1,32,32);
	computation1.Schedule("{S1[i,j]->[2,i1,j1,i2,j3,j4]: i1=floor(i/32) and j1=floor(j/32) and i2=i and j3=floor(j/4) and j4=j%4 and 0<=i<=1023 and 0<=j<=1023}");
	computation2.Split(0, 32);
	computation2.Split(2, 32);
	computation2.Interchange(1, 2);
	pgm.tag_parallel_dimension("S0", 1);
//	pgm.tag_vector_dimension("S1", 5);

	isl_union_map *schedule_map = pgm.get_schedule_map();

	// Create time space IR
	isl_union_set *time_space_representaion =
		coli::create_time_space_representation(isl_union_set_copy(pgm.get_iteration_spaces()), isl_union_map_copy(schedule_map));

	// Generate code
	isl_ast_build *ast_build = isl_ast_build_alloc(ctx);
	isl_options_set_ast_build_atomic_upper_bound(ctx, 1);
	ast_build = isl_ast_build_set_after_each_for(ast_build, &coli::for_halide_code_generator_after_for, NULL);
	ast_build = isl_ast_build_set_at_each_domain(ast_build, &coli::stmt_halide_code_generator, NULL);
	isl_ast_node *program = isl_ast_build_node_from_schedule_map(ast_build, isl_union_map_copy(schedule_map));
	isl_ast_build_free(ast_build);

	if (DEBUG)
		coli::isl_ast_node_dump_c_code(ctx, program);

	std::vector<std::string> generated_stmts, iterators;
	Halide::Internal::Stmt halide_pgm = coli::generate_Halide_stmt_from_isl_node(pgm, program, 0, generated_stmts, iterators);

	// Dump IRs
	pgm.dump_ISIR();
	pgm.dump_schedule();
	IF_DEBUG(coli::str_dump("\n\nTime Space IR:\n")); IF_DEBUG(isl_union_set_dump(time_space_representaion)); IF_DEBUG(coli::str_dump("\n\n"));
	coli::halide_IR_dump(halide_pgm);

	Halide::Target target;
	target.os = Halide::Target::OSX;
	target.arch = Halide::Target::X86;
	target.bits = 64;
	std::vector<Halide::Target::Feature> x86_features;
	x86_features.push_back(Halide::Target::AVX);
	x86_features.push_back(Halide::Target::SSE41);
	target.set_features(x86_features);

	Halide::Module::Module m("test1", target);
	m.append(Halide::Internal::LoweredFunc("test1", fct.get_args(), halide_pgm, Halide::Internal::LoweredFunc::External));

	Halide::compile_module_to_object(m, "LLVM_generated_code.o");

	return 0;
}
<commit_msg>Use inline declaration of vector<commit_after>#include <isl/set.h>
#include <isl/union_map.h>
#include <isl/union_set.h>
#include <isl/ast_build.h>
#include <isl/schedule.h>
#include <isl/schedule_node.h>

#include <coli/debug.h>
#include <coli/core.h>

#include <String.h>
#include <Halide.h>

int main(int argc, char **argv)
{
	isl_ctx *ctx = isl_ctx_alloc();
	coli::program pgm("program0");
	coli::function fct("function0", &pgm);

	// Declare the computations.  Each computation has:
	// (1) a Halide expression,
	// (2) an isl set representing its iteration space, and
	// (3) is attached to a function.
	coli::computation computation0(ctx, Halide::Expr((uint8_t) 3), "{S0[i,j]: 0<=i<=1000 and 0<=j<=1000}", &fct);
	coli::computation computation1(ctx, Halide::Expr((uint8_t) 5), "{S1[i,j]: 0<=i<=1023 and 0<=j<=1023}", &fct);
	coli::computation computation2(ctx, Halide::Expr((uint8_t) 7), "{S2[i,j]: 0<=i<=1023 and 0<=j<=1023}", &fct);

	// Create a memory buffer (2 dimensional).
	coli::buffer buf0("buf0", 2, {10,10}, Halide::Int(8), NULL, &fct);

	// Add the buffer as an argument to fct.
	fct.add_argument(buf0);

	// Map the computations to the buffers.
	computation0.SetAccess("{S0[i,j]->buf0[i, j]}");
	computation1.SetAccess("{S1[i,j]->buf0[0, 0]}");
	computation2.SetAccess("{S2[i,j]->buf0[i, j]}");

	// Set the schedule of each computation.
	computation0.Tile(0,1,32,32);
	computation1.Schedule("{S1[i,j]->[2,i1,j1,i2,j3,j4]: i1=floor(i/32) and j1=floor(j/32) and i2=i and j3=floor(j/4) and j4=j%4 and 0<=i<=1023 and 0<=j<=1023}");
	computation2.Split(0, 32);
	computation2.Split(2, 32);
	computation2.Interchange(1, 2);
	pgm.tag_parallel_dimension("S0", 1);
//	pgm.tag_vector_dimension("S1", 5);

	isl_union_map *schedule_map = pgm.get_schedule_map();

	// Create time space IR
	isl_union_set *time_space_representaion =
		coli::create_time_space_representation(isl_union_set_copy(pgm.get_iteration_spaces()), isl_union_map_copy(schedule_map));

	// Generate code
	isl_ast_build *ast_build = isl_ast_build_alloc(ctx);
	isl_options_set_ast_build_atomic_upper_bound(ctx, 1);
	ast_build = isl_ast_build_set_after_each_for(ast_build, &coli::for_halide_code_generator_after_for, NULL);
	ast_build = isl_ast_build_set_at_each_domain(ast_build, &coli::stmt_halide_code_generator, NULL);
	isl_ast_node *program = isl_ast_build_node_from_schedule_map(ast_build, isl_union_map_copy(schedule_map));
	isl_ast_build_free(ast_build);

	if (DEBUG)
		coli::isl_ast_node_dump_c_code(ctx, program);

	std::vector<std::string> generated_stmts, iterators;
	Halide::Internal::Stmt halide_pgm = coli::generate_Halide_stmt_from_isl_node(pgm, program, 0, generated_stmts, iterators);

	// Dump IRs
	pgm.dump_ISIR();
	pgm.dump_schedule();
	IF_DEBUG(coli::str_dump("\n\nTime Space IR:\n")); IF_DEBUG(isl_union_set_dump(time_space_representaion)); IF_DEBUG(coli::str_dump("\n\n"));
	coli::halide_IR_dump(halide_pgm);

	Halide::Target target;
	target.os = Halide::Target::OSX;
	target.arch = Halide::Target::X86;
	target.bits = 64;
	std::vector<Halide::Target::Feature> x86_features;
	x86_features.push_back(Halide::Target::AVX);
	x86_features.push_back(Halide::Target::SSE41);
	target.set_features(x86_features);

	Halide::Module::Module m("test1", target);
	m.append(Halide::Internal::LoweredFunc("test1", fct.get_args(), halide_pgm, Halide::Internal::LoweredFunc::External));

	Halide::compile_module_to_object(m, "LLVM_generated_code.o");

	return 0;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/initfiles/p9_psi_scom.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#include "p9_psi_scom.H"
#include <stdint.h>
#include <stddef.h>
#include <fapi2.H>
#include <attribute_ids.H>
#include <target_types.H>
#include <fapi2_attribute_service.H>
using namespace fapi2;

#define LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000    0b00000
#define LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000    0x000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_0x0000000000000000    0x0000000000000000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_0xC629000000000000    0xC629000000000000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_0x3902FFF800000000    0x3902FFF800000000

fapi2::ReturnCode p9_psi_scom(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& TGT0)
{
    fapi2::ReturnCode l_rc = 0;

    do
    {
        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x501290full, BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x501290f)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 0, 16, 48 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 16, 12, 36 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 0, 4, 32 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 32, 12, 20 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 0, 4, 16 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 48, 5, 11 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 0, 16,
                48 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 16, 12,
                36 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 0, 4, 32 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 32, 12,
                20 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 0, 4, 16 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 48, 5,
                11 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012906ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012906)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_0x0000000000000000, 0, 29, 35 );
        BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_0x0000000000000000, 0, 21, 14 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012907ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012907)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_0xC629000000000000, 0, 29, 35 );
        BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_0xC629000000000000, 0, 21, 14 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012903ull, BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012903)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_0x3902FFF800000000, 0,
                29, 35 );
        BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_0x3902FFF800000000, 0,
                17, 18 );

        l_rc = fapi2::putScom( TGT0, 0x5012903ull, BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012903)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x5012906ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012906)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x5012907ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012907)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x501290full, BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x501290f)");
            break;
        }

    }
    while(0);

    return l_rc;
}
<commit_msg>updates for memory integration<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/initfiles/p9_psi_scom.C $  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#include "p9_psi_scom.H"
#include <stdint.h>
#include <stddef.h>
#include <fapi2.H>
#include <attribute_ids.H>
#include <target_types.H>
#include <fapi2_attribute_service.H>
using namespace fapi2;

#define LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000    0b00000
#define LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000    0x000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_0b00000000000000000000000000000    0b00000000000000000000000000000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_0b11000110001010010000000000000    0b11000110001010010000000000000
#define LITERAL_BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_0b00111001000000101111111111111    0b00111001000000101111111111111

fapi2::ReturnCode p9_psi_scom(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& TGT0)
{
    fapi2::ReturnCode l_rc = 0;

    do
    {
        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x501290full, BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x501290f)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 16, 12, 27 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 32, 12, 43 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0x000, 48, 5, 59 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 16, 12,
                27 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 32, 12,
                43 );
        BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0.insert<uint64_t> (LITERAL_BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_0b00000, 48, 5,
                59 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012906ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012906)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_0b00000000000000000000000000000, 0, 29, 14 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012907ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012907)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_0b11000110001010010000000000000, 0, 29, 14 );

        fapi2::buffer<uint64_t> BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0;
        l_rc = fapi2::getScom( TGT0, 0x5012903ull, BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: getScom (0x5012903)");
            break;
        }

        BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0.insert<uint64_t>
        (LITERAL_BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_0b00111001000000101111111111111, 0, 29, 18 );

        l_rc = fapi2::putScom( TGT0, 0x5012903ull, BRIDGE_PSIHB_PSIHB_FIR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012903)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x5012906ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION0_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012906)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x5012907ull, BRIDGE_PSIHB_PSIHB_FIR_ACTION1_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x5012907)");
            break;
        }

        l_rc = fapi2::putScom( TGT0, 0x501290full, BRIDGE_PSIHB_PSIHB_ERROR_MASK_REG_scom0 );

        if (l_rc)
        {
            FAPI_ERR("ERROR executing: putScom (0x501290f)");
            break;
        }

    }
    while(0);

    return l_rc;
}
<|endoftext|>


<commit_before>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: chips/p9/utils/imageProcs/p9_scan_compression.H $             */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2016                                                         */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __P9_SCAN_COMPRESSION_H__
#define __P9_SCAN_COMPRESSION_H__

/// This header declares and documents the entry points defined in
/// p9_scan_compression.C.  Some constants are also required by the scan
/// decompression HOMER assembly procedures.

#ifndef __ASSEMBLER__

#include <stdint.h>

/// Compressed Scan Chain Data Structure Format
///
/// The compressed scan ring data structure must be 8-byte aligned in
/// memory. The container data structure consists of this 24-byte header
/// followed by an arbitrary number of 8 byte doublewords containing the
/// compressed scan data.  Images are always stored and processed in
/// big-endian byte order.  This container format is common across all
/// decompression algorithms.
///
/// Bytes - Content
///
/// 0:3 - A 32-bit "magic number" that identifies and validates the
/// compression algorithm and algorithm version used to compress the data.
///
/// 4:7 - The 32-bit size of the entire data structure in \e bytes.  Thi
/// consists of this 24-byte header plus the compressed scan data.  This value
/// is always a multiple of 8.
///
/// 8:11 - This 32-bit value is reserved to the compression
/// algorithm. Typically this field is used to record the 'size' of the
/// compressed string in units specific to each algorithm.
///
/// 12:15 - The length of the original scan chain in \e bits.
///
/// 16:23 - The 64 bit scan Region and type details
///
///
/// 24:27 - The 32 high-order bits of the value written to the Scan Select
/// register to set up the scan.  The Scan Select register only defines these
/// bits. (Planned to use scan scom register value)
///
/// 28 - The Scan Chain Data Structure version number
///
/// 29 - Flush-optimize : Is this byte is non-zero, the ring state to be
/// modified is the flush state of the ring.
///
/// 30 - The ring ID uniquely identifying the repair ring name.
///
/// 31 - The 7-bit pervasive chiplet Id + Multicast bit of the chiplet to
/// scan.  This value is loaded directly into P0.  The decompression
/// algorithms provide two entry points - one that uses this value as the
/// chiplet Id, and another that allows the caller to specify the chiplet Id
/// in the call.

typedef struct
{

    /// Magic number - See \ref scan_compression_magic
    uint32_t iv_magic;

    /// Total size in bytes, including the container header
    uint32_t iv_size;

    /// Reserved to the algorithm
    uint32_t iv_algorithmReserved;

    /// Length of the original scan chain in bits
    uint32_t iv_length;

    /// 64 bit scan select register value
    uint64_t iv_scanSelect;

    /// Data structure (header) version
    uint8_t iv_headerVersion;

    /// Flush-state optimization
    ///
    /// Normally, modifying the state of the ring requires XOR-ing the
    /// difference state (the compressed state) with the current ring state as
    /// it will appear in the Scan Data Register. If the current state of the
    /// ring is the scan-0 flush state, then by definition the Scan Data
    /// Register is always 0. Therefore we can simply write the difference to
    /// the Scan Data Register rather than using a read-XOR-write.
    uint8_t iv_flushOptimization;

    /// Ring ID uniquely identifying the repair name. (See the list of ring
    /// name vs ring IDs in p8_ring_identification.c).
    uint8_t iv_ringId;

    /// 7-bit pervasive chiplet Id + Multicast bit
    ///
    /// This field is right-justified in an 8-byte aligned doubleword so that
    /// the P0 register can be directly updated from the doubelword value in a
    /// data register.
    uint8_t iv_chipletId;

} CompressedScanData;

/// Endian-translate a CompressedScanData structure
///
/// \param o_data A pointer to a CompressedScanData structure to receive the
/// endian-translated form of \a i_data.
///
/// \param i_data A pointer to the original CompressedScanData structure.
///
/// This API performs an endian-converting copy of a CompressedScanData
/// structure. This copy is guaranteed to be done in such a way that \a i_data
/// and \a o_data may be the same pointer for in-place conversion.  Due to the
/// symmetry of reverse, translating a structure twice is always guaranteed to
/// return the origial structure to its original byte order.
void
compressed_scan_data_translate(CompressedScanData* o_data,
                               CompressedScanData* i_data);

/// Compress a scan string using the RS4 compression algorithm
///
/// \param[in,out] io_data This is a pointer to a memory area which must be
/// large enough to hold the worst-case result of compressing \a i_string (see
/// below).  Note that the CompressedScanData is always created in big-endian
/// format, however the caller can use compresed_scan_data_translate() to
/// create a copy of the header in host format.
///
/// \param[in] i_dataSize The size of \a io_data in bytes.
///
/// \param[out] o_imageSize The effective size of the entire compressed scan
/// data structure (header + compressed data) created in \a io_data, in bytes.
/// This value will always be a multiple of 8.
///
/// \param[in] i_data_str The string to compress.  Scan data to compress is
/// left-justified in this input string.
///
/// \param[in] i_care_str The care mask that identifies which bits in the
/// i_data_str that need to be scanned (written). String is left-justified.
///
/// \param[in] i_length The length of the input string in \e bits.  It is
/// assumed the \a i_string contains at least (\a i_length + 7) / 8 bytes.
///
/// \param[in] i_scanSelect The 64-bit value written to the Scan Select
/// register to set up for the scan.
///
/// \param[in] i_ringId The ring ID that uniquely identifies the ring name of
/// a repair ring. (See p8_ring_identification.c for more info.)
///
/// \param[in] i_chipletId The 7-bit value for the iv_chipletId field of the
/// CompressedScanData.
///
/// \param[in] i_flushOptimization This input parameter should be set to a
/// non-0 value if it is known that this ring difference will be applied to a
/// scan-0 flush state.  This will improve the performance of the
/// decompress-scan routine. If the initial state of the ring is unknown, set
/// this parameter to 0.
///
/// This API is required for integration with PHYP which does not support
/// malloc().  Applications in environments supporting malloc() can use
/// rs4_compress() instead.
///
/// The worst-case compression for RS4 requires 2 nibbles of control overhead
/// per 15 nibbles of data (17/15), plus a maximum of 2 nibbles of termination.
/// We always require this worst-case amount of memory including the header and
/// any rounding required to guarantee that the data size is a multiple of 8
/// bytes.  The final image size is also rounded up to a multiple of 8 bytes.
/// If the \a i_dataSize is less than this amount (based on \a i_length) the
/// call will fail.
///
/// \returns See \ref scan_compression_codes
int
_rs4_compress(CompressedScanData* io_data,
              uint32_t i_dataSize,
              uint32_t* o_imageSize,
              const uint8_t* i_data_str,
              const uint8_t* i_care_str,
              const uint32_t i_length,
              const uint64_t i_scanSelect,
              const uint8_t i_ringId,
              const uint8_t i_chipletId,
              const uint8_t i_flushOptimization);

/// Compress a scan string using the RS4 compression algorithm
///
/// \param[out] o_data This algorithm uses malloc() to allocate memory for the
/// compresed data, and returns a pointer to this memory in \a o_data. After
/// the call this memory is owned by the caller who is responsible for
/// free()-ing the data area once it is no longer required. Note that the
/// CompressedScanData is always created in big-endian format, however the
/// caller can use compresed_scan_data_translate() to create a copy of the
/// header in host format.
///
/// \param[out] o_size The effective size of the entire compressed scan data
/// structure (header + compressed data) pointed to by \a o_data, in bytes.
/// This value will always be a multiple of 8.
///
/// \param[in] i_data_str The string to compress.  Scan data to compress is
/// left-justified in this input string.
///
/// \param[in] i_care_str The care mask that identifies which bits in the
/// i_data_str that need to be scanned (written). String is left-justified.
///
/// \param[in] i_length The length of the input string in \e bits.  It is
/// assumed the \a i_string contains at least (\a i_length + 7) / 8 bytes.
///
/// \param[in] i_scanSelect The 64-bit value written to the Scan Select
/// register to set up for the scan. Only the 32 high-order bits are actually
/// stored.
///
/// \param[in] i_ringId The ring ID that uniquely identifies the ring name of
/// a repair ring. (See p8_ring_identification.c for more info.)
///
/// \param[in] i_chipletId The 7-bit value for the iv_chipletId field of the
/// CompressedScanData.
///
/// \param[in] i_flushOptimization This input parameter should be set to a
/// non-0 value if it is known that this ring difference will be applied to a
/// scan-0 flush state.  This will improve the performance of the
/// decompress-scan routine. If the initial state of the ring is unknown, set
/// this parameter to 0.
///
/// \returns See \ref scan_compression_codes
int
rs4_compress(CompressedScanData** o_data,
             uint32_t* o_size,
             const uint8_t* i_data_str,
             const uint8_t* i_care_str,
             const uint32_t i_length,
             const uint64_t i_scanSelect,
             const uint8_t i_ringId,
             const uint8_t i_chipletId,
             const uint8_t i_flushOptimization);

/// Decompress a scan string compressed using the RS4 compression algorithm
///
/// \param[in,out] io_string A caller-supplied data area to contain the
/// decompressed string. The \a i_stringSize must be large enough to contain
/// the decompressed string, which is the size of the original string in bits
/// rounded up to the nearest byte.
///
/// \param[in] i_stringSize The size (in bytes) of \a i_string.
///
/// \param[out] o_length The length of the decompressed string in \e bits.
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
/// decompressed.
///
/// This API is required for integration with PHYP which does not support
/// malloc().  Applications in environments supporting malloc() can use
/// rs4_decompress() instead.
///
/// \returns See \ref scan_compression_codes
int
_rs4_decompress(uint8_t* i_string,
                uint32_t i_stringSize,
                uint32_t* o_length,
                const CompressedScanData* i_data);

/// Decompress a scan string compressed using the RS4 compression algorithm
///
/// \param[out] o_string The API malloc()-s this data area to contain the
/// decompressed string. After this call the caller owns \a o_string and is
/// responsible for free()-ing this data area once it is no longer required.
///
/// \param[out] o_length The length of the decompressed string in \e bits.
/// The caller may assume that \a o_string contains at least (\a o_length + 7)
/// / 8 \e bytes.
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
/// decompressed.
///
/// \returns See \ref scan_compression_codes
int
rs4_decompress(uint8_t** o_string,
               uint32_t* o_length,
               const CompressedScanData* i_data);

/// Determine if an RS4 compressed scan string is all 0
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
///
/// \param[out] o_redundant Set to 1 if the RS4 string is the compressed form
/// of a scan string that is all 0; Otherwise set to 0.
///
/// \returns See \ref scan _compression_code
int
rs4_redundant(const CompressedScanData* i_data, int* o_redundant);

#endif  // __ASSEMBLER__

/// The current version of the CompressedScanData structure
///
/// This constant is required to be a #define to guarantee consistency between
/// the header format and cmopiled code.
#define COMPRESSED_SCAN_DATA_VERSION 1

/// The size of the CompressedScanData  structure
#define COMPRESSED_SCAN_DATA_SIZE (uint8_t)24

/// \defgroup scan_compression_magic Scan Compression Magic Numbers
/////
/// @ {

/// RS4 Magic
#define RS4_MAGIC (uint32_t)0x52533401       /* "RS4" + Version 0x01 */

/// @}

/// \defgroup scan_compression_codes Scan Compression Return Codes
///
/// @{

/// Normal return code
#define SCAN_COMPRESSION_OK (uint8_t)0

/// The (de)compression algorithm could not allocate enough memory for the
/// (de)compression.
#define SCAN_COMPRESSION_NO_MEMORY (uint8_t)1

/// Magic number mismatch on scan decompression
#define SCAN_DECOMPRESSION_MAGIC_ERROR (uint8_t)2

/// Decompression size error
///
/// Decompression produced a string of a size different than indicated in the
/// header, indicating either a bug or data corruption.  Note that the entire
/// application should be considered corrupted if this error occurs since it
/// may not be discovered until after the decompression buffer is
/// overrun. This error may also be returned by rs4_redundant() in the event
/// of inconsistencies in the compressed string.
#define SCAN_DECOMPRESSION_SIZE_ERROR (uint8_t)3

/// A buffer would overflow
///
/// Either the caller-supplied memory buffer to _rs4_decompress() was too
/// small to contain the decompressed string, or a caller-supplied buffer to
/// _rs4_compress() was not large enough to hold the worst-case compressed
/// string.
#define SCAN_COMPRESSION_BUFFER_OVERFLOW (uint8_t)4

/// @}

#endif  //  __P9_SCAN_COMPRESSION_H__
<commit_msg>p9_scan_compression: RS4v2 compression error return fix<commit_after>/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: chips/p9/utils/imageProcs/p9_scan_compression.H $             */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2016                                                         */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __P9_SCAN_COMPRESSION_H__
#define __P9_SCAN_COMPRESSION_H__

/// This header declares and documents the entry points defined in
/// p9_scan_compression.C.  Some constants are also required by the scan
/// decompression HOMER assembly procedures.

#ifndef __ASSEMBLER__

#include <stdint.h>

/// Compressed Scan Chain Data Structure Format
///
/// The compressed scan ring data structure must be 8-byte aligned in
/// memory. The container data structure consists of this 24-byte header
/// followed by an arbitrary number of 8 byte doublewords containing the
/// compressed scan data.  Images are always stored and processed in
/// big-endian byte order.  This container format is common across all
/// decompression algorithms.
///
/// Bytes - Content
///
/// 0:3 - A 32-bit "magic number" that identifies and validates the
/// compression algorithm and algorithm version used to compress the data.
///
/// 4:7 - The 32-bit size of the entire data structure in \e bytes.  Thi
/// consists of this 24-byte header plus the compressed scan data.  This value
/// is always a multiple of 8.
///
/// 8:11 - This 32-bit value is reserved to the compression
/// algorithm. Typically this field is used to record the 'size' of the
/// compressed string in units specific to each algorithm.
///
/// 12:15 - The length of the original scan chain in \e bits.
///
/// 16:23 - The 64 bit scan Region and type details
///
///
/// 24:27 - The 32 high-order bits of the value written to the Scan Select
/// register to set up the scan.  The Scan Select register only defines these
/// bits. (Planned to use scan scom register value)
///
/// 28 - The Scan Chain Data Structure version number
///
/// 29 - Flush-optimize : Is this byte is non-zero, the ring state to be
/// modified is the flush state of the ring.
///
/// 30 - The ring ID uniquely identifying the repair ring name.
///
/// 31 - The 7-bit pervasive chiplet Id + Multicast bit of the chiplet to
/// scan.  This value is loaded directly into P0.  The decompression
/// algorithms provide two entry points - one that uses this value as the
/// chiplet Id, and another that allows the caller to specify the chiplet Id
/// in the call.

typedef struct
{

    /// Magic number - See \ref scan_compression_magic
    uint32_t iv_magic;

    /// Total size in bytes, including the container header
    uint32_t iv_size;

    /// Reserved to the algorithm
    uint32_t iv_algorithmReserved;

    /// Length of the original scan chain in bits
    uint32_t iv_length;

    /// 64 bit scan select register value
    uint64_t iv_scanSelect;

    /// Data structure (header) version
    uint8_t iv_headerVersion;

    /// Flush-state optimization
    ///
    /// Normally, modifying the state of the ring requires XOR-ing the
    /// difference state (the compressed state) with the current ring state as
    /// it will appear in the Scan Data Register. If the current state of the
    /// ring is the scan-0 flush state, then by definition the Scan Data
    /// Register is always 0. Therefore we can simply write the difference to
    /// the Scan Data Register rather than using a read-XOR-write.
    uint8_t iv_flushOptimization;

    /// Ring ID uniquely identifying the repair name. (See the list of ring
    /// name vs ring IDs in p8_ring_identification.c).
    uint8_t iv_ringId;

    /// 7-bit pervasive chiplet Id + Multicast bit
    ///
    /// This field is right-justified in an 8-byte aligned doubleword so that
    /// the P0 register can be directly updated from the doubelword value in a
    /// data register.
    uint8_t iv_chipletId;

} CompressedScanData;

/// Endian-translate a CompressedScanData structure
///
/// \param o_data A pointer to a CompressedScanData structure to receive the
/// endian-translated form of \a i_data.
///
/// \param i_data A pointer to the original CompressedScanData structure.
///
/// This API performs an endian-converting copy of a CompressedScanData
/// structure. This copy is guaranteed to be done in such a way that \a i_data
/// and \a o_data may be the same pointer for in-place conversion.  Due to the
/// symmetry of reverse, translating a structure twice is always guaranteed to
/// return the origial structure to its original byte order.
void
compressed_scan_data_translate(CompressedScanData* o_data,
                               CompressedScanData* i_data);

/// Compress a scan string using the RS4 compression algorithm
///
/// \param[in,out] io_data This is a pointer to a memory area which must be
/// large enough to hold the worst-case result of compressing \a i_string (see
/// below).  Note that the CompressedScanData is always created in big-endian
/// format, however the caller can use compresed_scan_data_translate() to
/// create a copy of the header in host format.
///
/// \param[in] i_dataSize The size of \a io_data in bytes.
///
/// \param[out] o_imageSize The effective size of the entire compressed scan
/// data structure (header + compressed data) created in \a io_data, in bytes.
/// This value will always be a multiple of 8.
///
/// \param[in] i_data_str The string to compress.  Scan data to compress is
/// left-justified in this input string.
///
/// \param[in] i_care_str The care mask that identifies which bits in the
/// i_data_str that need to be scanned (written). String is left-justified.
///
/// \param[in] i_length The length of the input string in \e bits.  It is
/// assumed the \a i_string contains at least (\a i_length + 7) / 8 bytes.
///
/// \param[in] i_scanSelect The 64-bit value written to the Scan Select
/// register to set up for the scan.
///
/// \param[in] i_ringId The ring ID that uniquely identifies the ring name of
/// a repair ring. (See p8_ring_identification.c for more info.)
///
/// \param[in] i_chipletId The 7-bit value for the iv_chipletId field of the
/// CompressedScanData.
///
/// \param[in] i_flushOptimization This input parameter should be set to a
/// non-0 value if it is known that this ring difference will be applied to a
/// scan-0 flush state.  This will improve the performance of the
/// decompress-scan routine. If the initial state of the ring is unknown, set
/// this parameter to 0.
///
/// This API is required for integration with PHYP which does not support
/// malloc().  Applications in environments supporting malloc() can use
/// rs4_compress() instead.
///
/// The worst-case compression for RS4 requires 2 nibbles of control overhead
/// per 15 nibbles of data (17/15), plus a maximum of 2 nibbles of termination.
/// We always require this worst-case amount of memory including the header and
/// any rounding required to guarantee that the data size is a multiple of 8
/// bytes.  The final image size is also rounded up to a multiple of 8 bytes.
/// If the \a i_dataSize is less than this amount (based on \a i_length) the
/// call will fail.
///
/// \returns See \ref scan_compression_codes
int
_rs4_compress(CompressedScanData* io_data,
              uint32_t i_dataSize,
              uint32_t* o_imageSize,
              const uint8_t* i_data_str,
              const uint8_t* i_care_str,
              const uint32_t i_length,
              const uint64_t i_scanSelect,
              const uint8_t i_ringId,
              const uint8_t i_chipletId,
              const uint8_t i_flushOptimization);

/// Compress a scan string using the RS4 compression algorithm
///
/// \param[out] o_data This algorithm uses malloc() to allocate memory for the
/// compresed data, and returns a pointer to this memory in \a o_data. After
/// the call this memory is owned by the caller who is responsible for
/// free()-ing the data area once it is no longer required. Note that the
/// CompressedScanData is always created in big-endian format, however the
/// caller can use compresed_scan_data_translate() to create a copy of the
/// header in host format.
///
/// \param[out] o_size The effective size of the entire compressed scan data
/// structure (header + compressed data) pointed to by \a o_data, in bytes.
/// This value will always be a multiple of 8.
///
/// \param[in] i_data_str The string to compress.  Scan data to compress is
/// left-justified in this input string.
///
/// \param[in] i_care_str The care mask that identifies which bits in the
/// i_data_str that need to be scanned (written). String is left-justified.
///
/// \param[in] i_length The length of the input string in \e bits.  It is
/// assumed the \a i_string contains at least (\a i_length + 7) / 8 bytes.
///
/// \param[in] i_scanSelect The 64-bit value written to the Scan Select
/// register to set up for the scan. Only the 32 high-order bits are actually
/// stored.
///
/// \param[in] i_ringId The ring ID that uniquely identifies the ring name of
/// a repair ring. (See p8_ring_identification.c for more info.)
///
/// \param[in] i_chipletId The 7-bit value for the iv_chipletId field of the
/// CompressedScanData.
///
/// \param[in] i_flushOptimization This input parameter should be set to a
/// non-0 value if it is known that this ring difference will be applied to a
/// scan-0 flush state.  This will improve the performance of the
/// decompress-scan routine. If the initial state of the ring is unknown, set
/// this parameter to 0.
///
/// \returns See \ref scan_compression_codes
int
rs4_compress(CompressedScanData** o_data,
             uint32_t* o_size,
             const uint8_t* i_data_str,
             const uint8_t* i_care_str,
             const uint32_t i_length,
             const uint64_t i_scanSelect,
             const uint8_t i_ringId,
             const uint8_t i_chipletId,
             const uint8_t i_flushOptimization);

/// Decompress a scan string compressed using the RS4 compression algorithm
///
/// \param[in,out] io_string A caller-supplied data area to contain the
/// decompressed string. The \a i_stringSize must be large enough to contain
/// the decompressed string, which is the size of the original string in bits
/// rounded up to the nearest byte.
///
/// \param[in] i_stringSize The size (in bytes) of \a i_string.
///
/// \param[out] o_length The length of the decompressed string in \e bits.
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
/// decompressed.
///
/// This API is required for integration with PHYP which does not support
/// malloc().  Applications in environments supporting malloc() can use
/// rs4_decompress() instead.
///
/// \returns See \ref scan_compression_codes
int
_rs4_decompress(uint8_t* i_string,
                uint32_t i_stringSize,
                uint32_t* o_length,
                const CompressedScanData* i_data);

/// Decompress a scan string compressed using the RS4 compression algorithm
///
/// \param[out] o_string The API malloc()-s this data area to contain the
/// decompressed string. After this call the caller owns \a o_string and is
/// responsible for free()-ing this data area once it is no longer required.
///
/// \param[out] o_length The length of the decompressed string in \e bits.
/// The caller may assume that \a o_string contains at least (\a o_length + 7)
/// / 8 \e bytes.
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
/// decompressed.
///
/// \returns See \ref scan_compression_codes
int
rs4_decompress(uint8_t** o_string,
               uint32_t* o_length,
               const CompressedScanData* i_data);

/// Determine if an RS4 compressed scan string is all 0
///
/// \param[in] i_data A pointer to the CompressedScanData header + data to be
///
/// \param[out] o_redundant Set to 1 if the RS4 string is the compressed form
/// of a scan string that is all 0; Otherwise set to 0.
///
/// \returns See \ref scan _compression_code
int
rs4_redundant(const CompressedScanData* i_data, int* o_redundant);

#endif  // __ASSEMBLER__

/// The current version of the CompressedScanData structure
///
/// This constant is required to be a #define to guarantee consistency between
/// the header format and cmopiled code.
#define COMPRESSED_SCAN_DATA_VERSION 1

/// The size of the CompressedScanData  structure
#define COMPRESSED_SCAN_DATA_SIZE (uint8_t)24

/// \defgroup scan_compression_magic Scan Compression Magic Numbers
/////
/// @ {

/// RS4 Magic
#define RS4_MAGIC (uint32_t)0x52533401       /* "RS4" + Version 0x01 */

/// @}

/// \defgroup scan_compression_codes Scan Compression Return Codes
///
/// @{

/// Normal return code
#define SCAN_COMPRESSION_OK (uint8_t)0

/// The (de)compression algorithm could not allocate enough memory for the
/// (de)compression.
#define SCAN_COMPRESSION_NO_MEMORY (uint8_t)1

/// Magic number mismatch on scan decompression
#define SCAN_DECOMPRESSION_MAGIC_ERROR (uint8_t)2

/// Decompression size error
///
/// Decompression produced a string of a size different than indicated in the
/// header, indicating either a bug or data corruption.  Note that the entire
/// application should be considered corrupted if this error occurs since it
/// may not be discovered until after the decompression buffer is
/// overrun. This error may also be returned by rs4_redundant() in the event
/// of inconsistencies in the compressed string.
#define SCAN_DECOMPRESSION_SIZE_ERROR (uint8_t)3

/// A buffer would overflow
///
/// Either the caller-supplied memory buffer to _rs4_decompress() was too
/// small to contain the decompressed string, or a caller-supplied buffer to
/// _rs4_compress() was not large enough to hold the worst-case compressed
/// string.
#define SCAN_COMPRESSION_BUFFER_OVERFLOW (uint8_t)4

/// Inconsistent input data
///
/// 1 in data is masked by 0 in care mask
#define SCAN_COMPRESSION_INPUT_ERROR 5

/// Invalid transition in state machine
#define SCAN_COMPRESSION_STATE_ERROR 6

/// @}

#endif  //  __P9_SCAN_COMPRESSION_H__
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: b3dcolor.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: vg $ $Date: 2007-04-11 20:31:44 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _B3D_B3DCOLOR_HXX
#define _B3D_B3DCOLOR_HXX

#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif

/*************************************************************************
|*
|* Farbklasse fuer 3D. Besitzt einige Funktionen mehr, als die normale
|* Farbe
|*
\************************************************************************/

class B3dColor : public Color
{
public:
    B3dColor() : Color() {}
    B3dColor( ColorData nColor ) : Color(nColor) {}
    B3dColor( UINT8 nRed, UINT8 nGreen, UINT8 nBlue )
        : Color(nRed, nGreen, nBlue) {}
    B3dColor( UINT8 nTransparency, UINT8 nRed, UINT8 nGreen, UINT8 nBlue )
        : Color(nTransparency, nRed, nGreen, nBlue) {}
    B3dColor( const ResId& rResId ) : Color(rResId) {}
    B3dColor( const Color& rCol ) : Color(rCol) {}

    void CalcInBetween(Color& rOld1, Color& rOld2, double t);
    void CalcMiddle(Color& rOld1, Color& rOld2);
    void CalcMiddle(Color& rOld1, Color& rOld2, Color& rOld3);
    ULONG GetDistance(Color& rOld);

    // Addition, Subtraktion mit clamping
    B3dColor&   operator+=  (const B3dColor&);
    B3dColor&   operator-=  (const B3dColor&);
    B3dColor    operator+   (const B3dColor&) const;
    B3dColor    operator-   (const B3dColor&) const;

    // Multiplikation als Gewichtung, Anwendung einer Lampe
    // auf eine Farbe, Lampe als 2.Faktor
    B3dColor&   operator*=  (const B3dColor&);
    B3dColor    operator*   (const B3dColor&) const;

    // Multiplikation mit Faktor im Bereich [0.0 .. 1.0]
    B3dColor&   operator*=  (const double);
    B3dColor    operator*   (const double) const;

    // Zuweisung
    void operator=(const Color& rCol) { mnColor = rCol.GetColor(); }
};

#endif          // _B3D_B3DCOLOR_HXX
<commit_msg>INTEGRATION: CWS changefileheader (1.2.86); FILE MERGED 2008/04/01 15:19:26 thb 1.2.86.2: #i85898# Stripping all external header guards 2008/03/31 13:39:30 rt 1.2.86.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: b3dcolor.hxx,v $
 * $Revision: 1.3 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _B3D_B3DCOLOR_HXX
#define _B3D_B3DCOLOR_HXX

#include <tools/color.hxx>

/*************************************************************************
|*
|* Farbklasse fuer 3D. Besitzt einige Funktionen mehr, als die normale
|* Farbe
|*
\************************************************************************/

class B3dColor : public Color
{
public:
    B3dColor() : Color() {}
    B3dColor( ColorData nColor ) : Color(nColor) {}
    B3dColor( UINT8 nRed, UINT8 nGreen, UINT8 nBlue )
        : Color(nRed, nGreen, nBlue) {}
    B3dColor( UINT8 nTransparency, UINT8 nRed, UINT8 nGreen, UINT8 nBlue )
        : Color(nTransparency, nRed, nGreen, nBlue) {}
    B3dColor( const ResId& rResId ) : Color(rResId) {}
    B3dColor( const Color& rCol ) : Color(rCol) {}

    void CalcInBetween(Color& rOld1, Color& rOld2, double t);
    void CalcMiddle(Color& rOld1, Color& rOld2);
    void CalcMiddle(Color& rOld1, Color& rOld2, Color& rOld3);
    ULONG GetDistance(Color& rOld);

    // Addition, Subtraktion mit clamping
    B3dColor&   operator+=  (const B3dColor&);
    B3dColor&   operator-=  (const B3dColor&);
    B3dColor    operator+   (const B3dColor&) const;
    B3dColor    operator-   (const B3dColor&) const;

    // Multiplikation als Gewichtung, Anwendung einer Lampe
    // auf eine Farbe, Lampe als 2.Faktor
    B3dColor&   operator*=  (const B3dColor&);
    B3dColor    operator*   (const B3dColor&) const;

    // Multiplikation mit Faktor im Bereich [0.0 .. 1.0]
    B3dColor&   operator*=  (const double);
    B3dColor    operator*   (const double) const;

    // Zuweisung
    void operator=(const Color& rCol) { mnColor = rCol.GetColor(); }
};

#endif          // _B3D_B3DCOLOR_HXX
<|endoftext|>


<commit_before>//  (C) Copyright Gennadiy Rozental 2004.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
//  File        : $RCSfile$
//
//  Version     : $Revision$
//
//  Description : basic_cstring i/o implementation
// ***************************************************************************

#ifndef  BASIC_CSTRING_IO_HPP
#define  BASIC_CSTRING_IO_HPP

// Boost.Test
#include <boost/test/detail/basic_cstring/basic_cstring.hpp>

// STL
#include <iosfwd>
#include <string>

//____________________________________________________________________________//

namespace boost {

namespace unit_test {

#if  BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)

template<typename CharT>
inline std::ostream&
operator<<( std::ostream& os, basic_cstring<CharT> const& str )
{
    typedef typename ut_detail::bcs_base_char<CharT> char_type;
    char_type const* const beg = reinterpret_cast<char_type const* const>( str.begin() );
    char_type const* const end = reinterpret_cast<char_type const* const>( str.end() );
    os << std::basic_string<char_type>( beg, end - beg );

    return os;
}

#else

template<typename CharT1, typename Tr,typename CharT2>
inline std::basic_ostream<CharT1,Tr>&
operator<<( std::basic_ostream<CharT1,Tr>& os, basic_cstring<CharT2> const& str )
{
    CharT1 const* const beg = reinterpret_cast<CharT1 const* const>( str.begin() ); //!!
    CharT1 const* const end = reinterpret_cast<CharT1 const* const>( str.end() );
    os << std::basic_string<CharT1,Tr>( beg, end - beg );

    return os;
}

#endif

//____________________________________________________________________________//

} // namespace unit_test

} // namespace boost

// ***************************************************************************
//  Revision History :
//
//  $Log$
//  Revision 1.5  2004/06/29 04:31:49  rogeeff
//  gcc 2.95 fix
//
//  Revision 1.4  2004/06/05 11:02:15  rogeeff
//  std::traits usage reworked
//
//  Revision 1.3  2004/05/27 06:24:44  rogeeff
//  workaround for gcc 2.95 io
//
//  Revision 1.2  2004/05/21 06:19:35  rogeeff
//  licence update
//
//  Revision 1.1  2004/05/11 11:00:55  rogeeff
//  basic_cstring introduced and used everywhere
//  class properties reworked
//
// ***************************************************************************

#endif // BASIC_CSTRING_IO_HPP
<commit_msg>typo fix<commit_after>//  (C) Copyright Gennadiy Rozental 2004.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
//  File        : $RCSfile$
//
//  Version     : $Revision$
//
//  Description : basic_cstring i/o implementation
// ***************************************************************************

#ifndef  BASIC_CSTRING_IO_HPP
#define  BASIC_CSTRING_IO_HPP

// Boost.Test
#include <boost/test/detail/basic_cstring/basic_cstring.hpp>

// STL
#include <iosfwd>
#include <string>

//____________________________________________________________________________//

namespace boost {

namespace unit_test {

#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)

template<typename CharT>
inline std::ostream&
operator<<( std::ostream& os, basic_cstring<CharT> const& str )
{
    typedef typename ut_detail::bcs_base_char<CharT>::type char_type;
    char_type const* const beg = reinterpret_cast<char_type const* const>( str.begin() );
    char_type const* const end = reinterpret_cast<char_type const* const>( str.end() );
    os << std::basic_string<char_type>( beg, end - beg );

    return os;
}

#else

template<typename CharT1, typename Tr,typename CharT2>
inline std::basic_ostream<CharT1,Tr>&
operator<<( std::basic_ostream<CharT1,Tr>& os, basic_cstring<CharT2> const& str )
{
    CharT1 const* const beg = reinterpret_cast<CharT1 const* const>( str.begin() ); //!!
    CharT1 const* const end = reinterpret_cast<CharT1 const* const>( str.end() );
    os << std::basic_string<CharT1,Tr>( beg, end - beg );

    return os;
}

#endif

//____________________________________________________________________________//

} // namespace unit_test

} // namespace boost

// ***************************************************************************
//  Revision History :
//
//  $Log$
//  Revision 1.6  2004/06/30 07:52:56  rogeeff
//  typo fix
//
//  Revision 1.5  2004/06/29 04:31:49  rogeeff
//  gcc 2.95 fix
//
//  Revision 1.4  2004/06/05 11:02:15  rogeeff
//  std::traits usage reworked
//
//  Revision 1.3  2004/05/27 06:24:44  rogeeff
//  workaround for gcc 2.95 io
//
//  Revision 1.2  2004/05/21 06:19:35  rogeeff
//  licence update
//
//  Revision 1.1  2004/05/11 11:00:55  rogeeff
//  basic_cstring introduced and used everywhere
//  class properties reworked
//
// ***************************************************************************

#endif // BASIC_CSTRING_IO_HPP
<|endoftext|>


<commit_before>/*********************************************************************
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2009, Willow Garage, Inc.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of the Willow Garage nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *********************************************************************/

#ifndef CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_
#define CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
//     https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
  #ifdef __GNUC__
    #define CONTROL_TOOLBOX_EXPORT __attribute__ ((dllexport))
    #define CONTROL_TOOLBOX_IMPORT __attribute__ ((dllimport))
  #else
    #define CONTROL_TOOLBOX_EXPORT __declspec(dllexport)
    #define CONTROL_TOOLBOX_IMPORT __declspec(dllimport)
  #endif
  #ifdef CONTROL_TOOLBOX_BUILDING_LIBRARY
    #define CONTROL_TOOLBOX_PUBLIC CONTROL_TOOLBOX_EXPORT
  #else
    #define CONTROL_TOOLBOX_PUBLIC CONTROL_TOOLBOX_IMPORT
  #endif
  #define CONTROL_TOOLBOX_PUBLIC_TYPE CONTROL_TOOLBOX_PUBLIC
  #define CONTROL_TOOLBOX_LOCAL
#else
  #define CONTROL_TOOLBOX_EXPORT __attribute__ ((visibility("default")))
  #define CONTROL_TOOLBOX_IMPORT
  #if __GNUC__ >= 4
    #define CONTROL_TOOLBOX_PUBLIC __attribute__ ((visibility("default")))
    #define CONTROL_TOOLBOX_LOCAL  __attribute__ ((visibility("hidden")))
  #else
    #define CONTROL_TOOLBOX_PUBLIC
    #define CONTROL_TOOLBOX_LOCAL
  #endif
  #define CONTROL_TOOLBOX_PUBLIC_TYPE
#endif

#endif  // CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_<commit_msg>Update visibility_control.hpp<commit_after>/*********************************************************************
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2009, Willow Garage, Inc.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of the Willow Garage nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *********************************************************************/

#ifndef CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_
#define CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
//     https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
  #ifdef __GNUC__
    #define CONTROL_TOOLBOX_EXPORT __attribute__ ((dllexport))
    #define CONTROL_TOOLBOX_IMPORT __attribute__ ((dllimport))
  #else
    #define CONTROL_TOOLBOX_EXPORT __declspec(dllexport)
    #define CONTROL_TOOLBOX_IMPORT __declspec(dllimport)
  #endif
  #ifdef CONTROL_TOOLBOX_BUILDING_LIBRARY
    #define CONTROL_TOOLBOX_PUBLIC CONTROL_TOOLBOX_EXPORT
  #else
    #define CONTROL_TOOLBOX_PUBLIC CONTROL_TOOLBOX_IMPORT
  #endif
  #define CONTROL_TOOLBOX_PUBLIC_TYPE CONTROL_TOOLBOX_PUBLIC
  #define CONTROL_TOOLBOX_LOCAL
#else
  #define CONTROL_TOOLBOX_EXPORT __attribute__ ((visibility("default")))
  #define CONTROL_TOOLBOX_IMPORT
  #if __GNUC__ >= 4
    #define CONTROL_TOOLBOX_PUBLIC __attribute__ ((visibility("default")))
    #define CONTROL_TOOLBOX_LOCAL  __attribute__ ((visibility("hidden")))
  #else
    #define CONTROL_TOOLBOX_PUBLIC
    #define CONTROL_TOOLBOX_LOCAL
  #endif
  #define CONTROL_TOOLBOX_PUBLIC_TYPE
#endif

#endif  // CONTROL_TOOLBOX__VISIBILITY_CONTROL_HPP_
<|endoftext|>


<commit_before>/*
 * This is part of the FL library, a C++ Bayesian filtering library
 * (https://github.com/filtering-library)
 *
 * Copyright (c) 2014 Jan Issac (jan.issac@gmail.com)
 * Copyright (c) 2014 Manuel Wuthrich (manuel.wuthrich@gmail.com)
 *
 * Max-Planck Institute for Intelligent Systems, AMD Lab
 * University of Southern California, CLMC Lab
 *
 * This Source Code Form is subject to the terms of the MIT License (MIT).
 * A copy of the license can be found in the LICENSE file distributed with this
 * source code.
 */

/**
 * \file gaussian_filter.hpp
 * \date October 2014
 * \author Jan Issac (jan.issac@gmail.com)
 */

#ifndef FL__FILTER__GAUSSIAN__GAUSSIAN_FILTER_HPP
#define FL__FILTER__GAUSSIAN__GAUSSIAN_FILTER_HPP

#include <fl/filter/gaussian/gaussian_filter_kf.hpp>
#include <fl/filter/gaussian/gaussian_filter_ukf.hpp>
#include <fl/filter/gaussian/gaussian_filter_ukf_npn_aon.hpp>

#endif
<commit_msg>Added few Filter policy bases<commit_after>/*
 * This is part of the FL library, a C++ Bayesian filtering library
 * (https://github.com/filtering-library)
 *
 * Copyright (c) 2014 Jan Issac (jan.issac@gmail.com)
 * Copyright (c) 2014 Manuel Wuthrich (manuel.wuthrich@gmail.com)
 *
 * Max-Planck Institute for Intelligent Systems, AMD Lab
 * University of Southern California, CLMC Lab
 *
 * This Source Code Form is subject to the terms of the MIT License (MIT).
 * A copy of the license can be found in the LICENSE file distributed with this
 * source code.
 */

/**
 * \file gaussian_filter.hpp
 * \date October 2014
 * \author Jan Issac (jan.issac@gmail.com)
 */

#ifndef FL__FILTER__GAUSSIAN__GAUSSIAN_FILTER_HPP
#define FL__FILTER__GAUSSIAN__GAUSSIAN_FILTER_HPP

namespace fl
{

struct FadingMemoryPolicy // None, alpha, decay
{
};

struct ValidationGatePolicy // Eucledian, ellipsoid
{
};

struct UpdatePolicy // normal, joseph
{

};

}

#include <fl/filter/gaussian/gaussian_filter_kf.hpp>
#include <fl/filter/gaussian/gaussian_filter_ukf.hpp>
#include <fl/filter/gaussian/gaussian_filter_ukf_npn_aon.hpp>

#endif
<|endoftext|>