Commit 104616e7 authored by Antônio Augusto Fröhlich's avatar Antônio Augusto Fröhlich
Browse files

An additional cleanup to make the first exercises more easy for the students

parent 4b16242e
// This work is licensed under the EPOS Software License v1.0.
// A copy of this license is available at the EPOS system source tree root.
// A copy of this license is also available online at:
// http://epos.lisha.ufsc.br/EPOS+Software+License+v1.0
// Note that EPOS Software License applies to both source code and executables.
# EPOS Application Makefile
include ../makedefs
all: install
$(APPLICATION): $(APPLICATION).o $(LIB)/*
$(ALD) $(ALDFLAGS) -o $@ $(APPLICATION).o
$(APPLICATION).o: $(APPLICATION).cc $(SRC)
$(ACC) $(ACCFLAGS) -o $@ $<
install: $(APPLICATION)
ifndef GDB
$(STRIP) -o $(APPLICATION).tmp $<
else
$(INSTALL) $< $(APPLICATION).tmp
endif
$(INSTALL) $(APPLICATION).tmp $(IMG)/$(APPLICATION)
$(CLEAN) $(APPLICATION).tmp
clean:
$(CLEAN) *.o $(APPLICATION)
\ No newline at end of file
../src/abstraction/semaphore_test.cc
\ No newline at end of file
../src/abstraction/synchronizer_test.cc
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="1">
<profile kind="CodeFormatterProfile" name="EPOS" version="1">
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_member_access" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list" value="80"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_enumerator_list" value="48"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_declarator_list" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration" value="82"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_expression_list" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression" value="82"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_compact_if" value="0"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_assignment" value="32"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration" value="82"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.cdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="82"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain" value="18"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.indentation.size" value="8"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration" value="next_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters" value="insert"/>
<setting id="org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments" value="do not insert"/>
</profile>
</profiles>
# EPOS Configuration Makefile
include ../makedefs
all: $(APP)/$(APPLICATION)_traits.h eposcc.conf eposmkbi.conf $(INCLUDE)/system/config.h
sed -e 's/^#define ARCH.*$$/#define ARCH $(ARCH)/' -i $(INCLUDE)/system/config.h
sed -e 's/^#define MACH.*$$/#define MACH $(MACH)/' -i $(INCLUDE)/system/config.h
sed -e 's/^#define APPLICATION.*$$/#define APPLICATION $(APPLICATION)/' -i $(INCLUDE)/system/config.h
$(APP)/$(APPLICATION)_traits.h:
$(INSTALL) $(INCLUDE)/system/traits.h $@
eposcc.conf:
@echo "ARCH=$(ARCH)" > $@
@echo "MACH=$(MACH)" >> $@
@echo "TOOLS_PREFIX=$(COMP_PREFIX)" >> $@
@echo "APP_CODE=$(APP_CODE_ADDR)" >> $@
@echo "APP_DATA=$(APP_DATA_ADDR)" >> $@
@echo "MACH_CC_FLAGS='$(MACH_CC_FLAGS)'" >> $@
@echo "MACH_LD_FLAGS='$(MACH_LD_FLAGS)'" >> $@
@echo "MACH_CODE_NAME='$(MACH_CODE_NAME)'" >> $@
@echo "MACH_DATA_NAME='$(MACH_DATA_NAME)'" >> $@
eposmkbi.conf:
@echo "MODE=$(MODE)" > $@
@echo "MACH=$(MACH)" >> $@
@echo "ARCH=$(ARCH)" >> $@
@echo "CLOCK=$(ARCH_CLOCK)" >> $@
@echo "WORD_SIZE=$(ARCH_WORD_SIZE)" >> $@
@echo "ENDIANESS=$(ARCH_ENDIANESS)" >> $@
@echo "MEM_BASE=$(MEM_BASE)" >> $@
@echo "MEM_TOP=$(MEM_TOP)" >> $@
@echo "BOOT_LENGTH_MIN=$(BOOT_LENGTH_MIN)" >> $@
@echo "BOOT_LENGTH_MAX=$(BOOT_LENGTH_MAX)" >> $@
clean: $(APP)/$(APPLICATION)_traits.h
sed -e 's/^#define ARCH.*$$/#define ARCH xxx/' -i $(INCLUDE)/system/config.h
sed -e 's/^#define MACH.*$$/#define MACH xxx/' -i $(INCLUDE)/system/config.h
sed -e 's/^#define APP.*$$/#define APPLICATION xxx/' -i $(INCLUDE)/system/config.h
$(CLEAN) *.conf
FORCE:
\ No newline at end of file
# EPOS Image Makefile
include ../makedefs
IMAGE := $(addsuffix .img,$(APPLICATION))
OUTPUT := $(addsuffix .out,$(APPLICATION))
TESTS := $(shell find *_test 2> /dev/null)
TEST_IMAGES := $(addsuffix .img,$(TESTS))
TEST_OUTPUTS := $(addsuffix .out,$(TESTS))
all: $(IMAGE)
test: $(TEST_IMAGES)
run: $(OUTPUT)
debug: $(IMAGE)
$(EMULATOR) $(IMAGE) | $(TEE) $(OUTPUT) &
$(DEBUGGER) $(APP)/$(APPLICATION)
runtest: $(TEST_OUTPUTS)
clean:
$(CLEAN) *_boot *_setup *_init *_system $(APPLICATION) $(TESTS)
// EPOS Alarm Abstraction Declarations
#ifndef __alarm_h
#define __alarm_h
#include <utility/queue.h>
#include <utility/handler.h>
#include <tsc.h>
#include <rtc.h>
#include <timer.h>
#include <semaphore.h>
__BEGIN_SYS
class Alarm
{
public:
typedef TSC::Time_Stamp Time_Stamp;
typedef TSC::Hertz Hertz;
typedef Timer::Tick Tick;
typedef RTC::Microsecond Microsecond;
// An alarm handler
typedef Function_Handler Handler;
// Infinite times (for alarms)
enum { INFINITE = -1 };
private:
typedef Relative_Queue<Alarm, Tick> Queue;
public:
Alarm(const Microsecond & time, Handler handler, int times = 1);
~Alarm();
static Hertz frequency() { return _timer->frequency(); }
static void delay(const Microsecond & time);
static int init();
private:
static Microsecond period() {
return 1000000 / frequency();
}
static Tick ticks(const Microsecond & time) {
return (time + period() / 2) / period();
}
static void lock() { Thread::lock(); }
static void unlock() { Thread::unlock(); }
static void handler(void);
private:
Tick _ticks;
Handler _handler;
int _times;
Queue::Element _link;
static Alarm_Timer * _timer;
static volatile Tick _elapsed;
static Queue _requests;
};
class Delay
{
private:
typedef RTC::Microsecond Microsecond;
public:
Delay(const Microsecond & time): _time(time) { Alarm::delay(_time); }
private:
Microsecond _time;
};
__END_SYS
#endif
// EPOS Global Application Abstraction Declarations
#ifndef __application_h
#define __application_h
#include <utility/heap.h>
__BEGIN_SYS
class Application
{
public:
static Heap * const heap() { return &_heap; }
static void init();
private:
static Heap _heap;
};
__END_SYS
#include <utility/malloc.h>
#endif
// EPOS IA32 CPU Mediator Declarations
#ifndef __ia32_h
#define __ia32_h
#include <cpu.h>
__BEGIN_SYS
class IA32: public CPU_Common
{
public:
// CPU Flags
typedef Reg32 Flags;
enum {
FLAG_CF = 0x00000001,
FLAG_PF = 0x00000004,
FLAG_AF = 0x00000010,
FLAG_ZF = 0x00000040,
FLAG_SF = 0x00000080,
FLAG_TF = 0x00000100,
FLAG_IF = 0x00000200,
FLAG_DF = 0x00000400,
FLAG_OF = 0x00000800,
FLAG_IOPL1 = 0x00001000,
FLAG_IOPL2 = 0x00002000,
FLAG_NT = 0x00004000,
FLAG_RF = 0x00010000,
FLAG_VM = 0x00020000,
FLAG_AC = 0x00040000,
FLAG_VIF = 0x00080000,
FLAG_VIP = 0x00100000,
FLAG_ID = 0x00200000,
FLAG_DEFAULTS = FLAG_IF,
// Mask to clear flags (by ANDing)
FLAG_CLEAR = ~(FLAG_TF | FLAG_IOPL1 | FLAG_IOPL2 | FLAG_NT |
FLAG_RF | FLAG_VM | FLAG_AC)
};
// Exceptions
enum Exceptions { // GCC BUG (anonymous enum in templates)
EXC_BASE = 0x00,
EXC_DIV0 = 0x00,
EXC_DEBUG = 0x01,
EXC_NMI = 0x02,
EXC_BP = 0x03,
EXC_OVFLOW = 0x04,
EXC_BOUND = 0x05,
EXC_INVOP = 0x06,
EXC_NODEV = 0x07,
EXC_DOUBLE = 0x08,
EXC_FPU_OR = 0x09,
EXC_INVTSS = 0x0a,
EXC_NOTPRE = 0x0b,
EXC_STACK = 0x0c,
EXC_GPF = 0x0d,
EXC_PF = 0x0e,
EXC_RESERV = 0x0f,
EXC_FPU = 0x10,
EXC_ALIGN = 0x11,
EXC_BUS = 0x12,
EXC_LAST = 0x1f
};
// CR0 Flags
enum {
CR0_PE = 0x00000001,
CR0_MP = 0x00000002,
CR0_EM = 0x00000004,
CR0_TS = 0x00000008,
CR0_ET = 0x00000010,
CR0_NE = 0x00000020,
CR0_WP = 0x00010000,
CR0_AM = 0x00040000,
CR0_NW = 0x20000000,
CR0_CD = 0x40000000,
CR0_PG = 0x80000000,
// Mask to clear flags (by ANDing)
CR0_CLEAR = (CR0_PE | CR0_EM | CR0_TS | CR0_NE | CR0_AM |
CR0_NW | CR0_CD),
// Mask to set flags (by ORing)
CR0_SET = (CR0_PE | CR0_MP | CR0_ET | CR0_PG)
};
// Segment Flags
enum {
SEG_ACC = 0x01,
SEG_RW = 0x02,
SEG_CONF = 0x04,
SEG_CODE = 0x08,
SEG_NOSYS = 0x10,
SEG_DPL1 = 0x20,
SEG_DPL2 = 0x40,
SEG_PRE = 0x80,
SEG_TSS = 0x09,
SEG_INT = 0x0e,
SEG_TRAP = 0x0f,
SEG_32 = 0x40,
SEG_4K = 0x80,
SEG_FLT_CODE = (SEG_PRE | SEG_NOSYS | SEG_CODE | SEG_ACC),
SEG_FLT_DATA = (SEG_PRE | SEG_NOSYS | SEG_RW | SEG_ACC),
SEG_SYS_CODE = (SEG_PRE | SEG_NOSYS | SEG_RW | SEG_CODE | SEG_ACC),
SEG_SYS_DATA = (SEG_PRE | SEG_NOSYS | SEG_RW | SEG_ACC),
SEG_APP_CODE = (SEG_PRE | SEG_NOSYS | SEG_DPL2 | SEG_DPL1 |
SEG_CODE | SEG_ACC), // P, DPL=3, S, C, W, A
SEG_APP_DATA = (SEG_PRE | SEG_NOSYS | SEG_DPL2 | SEG_DPL1 |
SEG_RW | SEG_ACC), // P, DPL=3, S, W, A
// SEG_SYS_CODE = (SEG_PRE | SEG_NOSYS | SEG_DPL2 | SEG_DPL1 |
// SEG_CODE | SEG_ACC), // P, DPL=3, S, C, W, A
// SEG_SYS_DATA = (SEG_PRE | SEG_NOSYS | SEG_DPL2 | SEG_DPL1 |
// SEG_RW | SEG_ACC), // P, DPL=3, S, W, A
SEG_IDT_ENTRY = (SEG_PRE | SEG_INT )
};
// DPL/RPL for application (user) and system (supervisor) modes
enum {
PL_APP = 3, // GDT, RPL=3
PL_SYS = 0 // GDT, RPL=0
// PL_SYS = 3 // GDT, RPL=0
};
// GDT Layout
enum GDT_Layout { // GCC BUG (anonymous enum in templates)
GDT_NULL = 0,
GDT_FLT_CODE = 1,
GDT_FLT_DATA = 2,
GDT_SYS_CODE = GDT_FLT_CODE,
GDT_SYS_DATA = GDT_FLT_DATA,
GDT_APP_CODE = 3,
GDT_APP_DATA = 4,
GDT_LAST = GDT_APP_DATA
};
// GDT Selectors
enum {
SEL_FLT_CODE = (GDT_FLT_CODE << 3) | PL_SYS,
SEL_FLT_DATA = (GDT_FLT_DATA << 3) | PL_SYS,
SEL_APP_CODE = (GDT_APP_CODE << 3) | PL_APP,
SEL_APP_DATA = (GDT_APP_DATA << 3) | PL_APP,
SEL_SYS_CODE = (GDT_SYS_CODE << 3) | PL_SYS,
SEL_SYS_DATA = (GDT_SYS_DATA << 3) | PL_SYS
};
// GDT Entry
class GDT_Entry {
public:
GDT_Entry() {}
GDT_Entry(Reg32 b, Reg32 l, Reg8 f)
: limit_15_00((Reg16)l),
base_15_00((Reg16)b),
base_23_16((Reg8)(b >> 16)),
p_dpl_s_type(f),
g_d_0_a_limit_19_16(((f & SEG_NOSYS)?SEG_4K | SEG_32 : 0) |
((Reg8)(l >> 16))),
base_31_24((Reg8)(b >> 24)) {}
friend Debug & operator << (Debug & db, const GDT_Entry & g) {
db << "{bas=" << (void *)((g.base_31_24 << 24) |
(g.base_23_16 << 16) |
g.base_15_00)
<< ",lim=" << (void *)(((g.g_d_0_a_limit_19_16 & 0xf) << 16) |
g.limit_15_00)
<< ",p=" << (g.p_dpl_s_type >> 7)
<< ",dpl=" << ((g.p_dpl_s_type >> 5) & 0x3)
<< ",s=" << ((g.p_dpl_s_type >> 4) & 0x1)
<< ",typ=" << (g.p_dpl_s_type & 0xf)
<< ",g=" << (g.g_d_0_a_limit_19_16 >> 7)
<< ",d=" << ((g.g_d_0_a_limit_19_16 >> 6) & 0x1)
<< ",a=" << ((g.g_d_0_a_limit_19_16 >> 4) & 0x1) << "}";
return db;
}
private:
Reg16 limit_15_00;
Reg16 base_15_00;
Reg8 base_23_16;
Reg8 p_dpl_s_type;
Reg8 g_d_0_a_limit_19_16;
Reg8 base_31_24;
};
// IDT Entry
class IDT_Entry {
public:
IDT_Entry() {}
IDT_Entry(Reg16 s, Reg32 o, Reg16 f)
: offset_15_00((Reg16)o),
selector(s << 3),
zero(0),
p_dpl_0_d_1_1_0(f),
offset_31_16((Reg16)(o >> 16)) {}
Reg32 offset() const { return (offset_31_16 << 16) | offset_15_00; }
friend Debug & operator << (Debug & db, const IDT_Entry & i) {
db << "{sel=" << (i.selector >> 3)
<< ",off=" << (void *)i.offset()
<< ",p=" << (i.p_dpl_0_d_1_1_0 >> 7)
<< ",dpl=" << ((i.p_dpl_0_d_1_1_0 >> 5) & 0x3)
<< ",d=" << ((i.p_dpl_0_d_1_1_0 >> 4) & 0x1) << "}";
return db;
}
private:
Reg16 offset_15_00;
Reg16 selector;
Reg8 zero;
Reg8 p_dpl_0_d_1_1_0;
Reg16 offset_31_16;
};
static const unsigned int IDT_ENTRIES = 256;
// TSS no longer used, since software context