Merged very large and much appreciated patch from Chris Johns

<cjohns@plessey.com.au>.  This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.
This commit is contained in:
Joel Sherrill
1997-07-31 22:13:29 +00:00
parent 91333c27bd
commit 0074691a67
90 changed files with 13689 additions and 0 deletions
+5
View File
@@ -101,6 +101,11 @@ The following persons/organizations have made contributions:
Laboratory submitted a port of the KA9Q TCP/IP stack to RTEMS as
well as a network device driver for the gen68360 BSP.
+ Chris Johns (cjohns@plessey.com.au) submitted the ods68302 BSP which
offers easier configuration than its counterpart gen68302. Chris
also submitted the RTEMS++ C++ class library and test code for
that library.
Finally, the RTEMS project would like to thank those who have contributed
to the other free software efforts which RTEMS utilizes. The primary RTEMS
development environment is from the Free Software Foundation (the GNU
+127
View File
@@ -0,0 +1,127 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsEvent class.
This class allows the user to send and receive RTEMS events to a task.
------------------------------------------------------------------------ */
#if !defined(_rtemsEvent_h_)
#define _rtemsEvent_h_
#include <rtems++/rtemsStatusCode.h>
#include <rtems++/rtemsTask.h>
/* ----
rtemsEvent
*/
class rtemsEvent
: public rtemsStatusCode
{
public:
// attribute a task can have
enum WaitMode { wait = RTEMS_WAIT,
no_wait = RTEMS_NO_WAIT};
enum Condition { any = RTEMS_EVENT_ANY,
all = RTEMS_EVENT_ALL};
// only the first 4 characters of the name are taken
// connect to a task
rtemsEvent(const char* name, rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsEvent(const rtemsEvent& event);
rtemsEvent();
virtual ~rtemsEvent();
// connect to an existing task object, will not be the owner
const rtemsEvent& operator=(const rtemsEvent& event);
virtual const rtems_status_code connect(const char *name,
const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// send an event
inline const rtems_status_code send(const rtems_id task,
const rtems_event_set events);
inline const rtems_status_code send(const rtemsTask& task,
const rtems_event_set events) ;
inline const rtems_status_code send(const rtems_event_set events);
// receive an event, can block a task if no events waiting
inline const rtems_status_code receive(const rtems_event_set event_in,
rtems_event_set& event_out,
const rtems_interval micro_secs = 0,
const WaitMode wait = wait,
const Condition condition = any);
// object id, and name
const rtems_id task_id_is() const { return id; }
const rtems_name task_name_is() const { return name; }
private:
// task name
rtems_name name;
// the rtems task id, object handle
rtems_id id;
};
const rtems_status_code rtemsEvent::send(const rtems_id task,
const rtems_event_set events)
{
set_status_code(rtems_event_send(task, events));
return last_status_code();
}
const rtems_status_code rtemsEvent::send(const rtemsTask& task,
const rtems_event_set events)
{
set_status_code(rtems_event_send(task.id_is(), events));
return last_status_code();
}
const rtems_status_code rtemsEvent::send(const rtems_event_set events)
{
set_status_code(rtems_event_send(id, events));
return last_status_code();
}
const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in,
rtems_event_set& event_out,
const rtems_interval micro_secs,
const WaitMode wait,
const Condition condition)
{
rtems_interval usecs =
micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
_TOD_Microseconds_per_tick : micro_secs;
set_status_code(rtems_event_receive(event_in,
wait | condition,
TOD_MICROSECONDS_TO_TICKS(usecs),
&event_out));
return last_status_code();
}
#endif // _rtemsEvent_h_
+105
View File
@@ -0,0 +1,105 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsInterrupt class.
This class catches an interrupt and passes control to the user's
derived class throught the handler method.
The interrupt is released back to the previous handler when this
object destructs.
The old handler can be chained to after the interrupt is
caught. Watch the stack usage!
More than one instance of this class can catch the same vector. The
application will have to chain to the other objects if required. If
the old handler is not an instance of this class the chain is passed
as "void (*)(void)". If it is an instance of this class, the handler
method is directly called.
The isr catch extends the documented return codes with :
RTEMS_RESOURCE_IN_USE = interrupt already caught
------------------------------------------------------------------------ */
#if !defined(_rtemsInterrupt_h_)
#define _rtemsInterrupt_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsInterrupt
*/
class rtemsInterrupt
: public rtemsStatusCode
{
public:
rtemsInterrupt();
virtual ~rtemsInterrupt();
// catch the interrupt
virtual const rtems_status_code isr_catch(const rtems_vector_number vector);
// release the interrupt back to the previous handle
virtual const rtems_status_code release();
// the old handler
const rtems_isr_entry old_isr_handler() const { return old_handler; }
protected:
// called after the interrupt is caught and it goes off
virtual void handler() = 0;
// chain to the previous handler,
inline void chain() const;
private:
const rtemsInterrupt& operator=(const rtemsInterrupt& );
Interrupt(const rtemsInterrupt& );
// the vector caught
rtems_vector_number vector;
// true when the interrupt is caught
bool caught;
// returned when catching the interrupt
rtems_isr_entry old_handler;
// old interrupt table entry
rtemsInterrupt *old_interrupt;
// common handler to redirect the interrupts
static void redirector(rtems_vector_number vector);
};
void rtemsInterrupt::chain() const
{
if (old_interrupt)
old_interrupt->handler();
else if (old_handler)
((void(*)()) old_handler)();
}
#endif // _rtemsInterrupt_h_
@@ -0,0 +1,176 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsMessageQueue class.
This class allows the user to create a RTEMS message queue, or to
access and manage an already existing message queue.
The first constructor with the message queue parameters creates a
RTEMS message queue object. The destructor of this object also
deletes the message queue object. The last status code should be
checked after construction to see if the create completed
successfully.
The second constructor connects to an existing message queue
object. The last status code should be checked after construction to
see if the message queue existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
The fourth constructor allows for the message queue to be created
after construction, or to connect to a message queue later.
------------------------------------------------------------------------ */
#if !defined(_rtemsMessageQueue_h_)
#define _rtemsMessageQueue_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsMessageQueue
*/
class rtemsMessageQueue
: public rtemsStatusCode
{
public:
// attribute a message queue can have
enum WaitMode { wait_by_fifo = RTEMS_FIFO,
wait_by_priority = RTEMS_PRIORITY };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken
// creates a message queue
rtemsMessageQueue(const char* name,
const rtems_unsigned32 count,
const rtems_unsigned32 max_message_size,
const WaitMode wait_mode = wait_by_fifo,
const Scope scope = local);
// connects to a message queue
rtemsMessageQueue(const char *name, const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsMessageQueue(const rtemsMessageQueue& message_queue);
rtemsMessageQueue();
// only the creator's destructor will delete the actual object
virtual ~rtemsMessageQueue();
// create or destroy (delete) the message queue
virtual const rtems_status_code create(const char* name,
const rtems_unsigned32 count,
const rtems_unsigned32 max_message_size,
const WaitMode wait_mode = wait_by_fifo,
const Scope scope = local);
virtual const rtems_status_code destroy();
// connect to an existing message queue object, will not be the owner
const rtemsMessageQueue& operator=(const rtemsMessageQueue& message_queue);
virtual const rtems_status_code connect(const char *name,
const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// send a message of size from the buffer
inline const rtems_status_code send(const void *buffer,
const rtems_unsigned32 size);
inline const rtems_status_code urgent(const void *buffer,
const rtems_unsigned32 size);
inline const rtems_status_code broadcast(const void *buffer,
const rtems_unsigned32 size,
rtems_unsigned32& count);
// receive a message of size, the timeout is in micro-secs
inline const rtems_status_code receive(const void *buffer,
rtems_unsigned32& size,
rtems_interval micro_secs = RTEMS_NO_TIMEOUT,
bool wait = true);
// flush a message queue, returning the number of messages dropped
inline const rtems_status_code flush(rtems_unsigned32& size);
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
private:
// make this object reference an invalid RTEMS object
void make_invalid();
// message queue name
rtems_name name;
char name_str[5];
// owner, true if this object owns the message queue
// will delete the message queue when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
};
const rtems_status_code rtemsMessageQueue::send(const void *buffer,
const rtems_unsigned32 size)
{
return set_status_code(rtems_message_queue_send(id, (void*) buffer, size));
}
const rtems_status_code rtemsMessageQueue::urgent(const void *buffer,
const rtems_unsigned32 size)
{
return set_status_code(rtems_message_queue_urgent(id, (void*) buffer, size));
}
const rtems_status_code rtemsMessageQueue::broadcast(const void *buffer,
const rtems_unsigned32 size,
rtems_unsigned32& count)
{
return set_status_code(rtems_message_queue_broadcast(id,
(void*) buffer,
size,
&count));
}
const rtems_status_code rtemsMessageQueue::receive(const void *buffer,
rtems_unsigned32& size,
rtems_interval micro_secs,
bool wait)
{
rtems_interval usecs =
micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
_TOD_Microseconds_per_tick : micro_secs;
return set_status_code(rtems_message_queue_receive(id,
(void*) buffer,
&size,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
TOD_MICROSECONDS_TO_TICKS(usecs)));
}
const rtems_status_code rtemsMessageQueue::flush(rtems_unsigned32& count)
{
return set_status_code(rtems_message_queue_flush(id, &count));
}
#endif // _rtemsMessageQueue_h_
+145
View File
@@ -0,0 +1,145 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsSemaphore class.
This class allows the user to create a RTEMS semaphore, or to use an
already existing semaphore. The type of semaphore is decitated by
the constructor used.
The first constructor with the semaphore parameters creates a RTEMS
semaphore object. The destructor of this object also deletes the
semaphore object. The last status code should be checked after
construction to see if the semaphore create was successfull.
The second constructor connects to an existing. The last status code
should be checked after construction to see if the semaphore
existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
------------------------------------------------------------------------ */
#if !defined(_rtemsSemaphore_h_)
#define _rtemsSemaphore_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsSemaphore
*/
class rtemsSemaphore
: public rtemsStatusCode
{
public:
// attribute a semaphore can have
enum WaitMode { wait_by_fifo = RTEMS_FIFO,
wait_by_priority = RTEMS_PRIORITY };
enum Type { binary = RTEMS_BINARY_SEMAPHORE,
counting = RTEMS_COUNTING_SEMAPHORE };
enum Priority { no_priority_inherit = RTEMS_NO_INHERIT_PRIORITY,
inherit_priority = RTEMS_INHERIT_PRIORITY };
enum Ceiling { no_priority_ceiling = RTEMS_NO_PRIORITY_CEILING,
priority_ceiling = RTEMS_PRIORITY_CEILING };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken,
// the counter must be set to 1 for binary semaphores
// create a semaphore object
rtemsSemaphore(const char* name,
const Scope scope = local,
const rtems_unsigned32 counter = 1,
const WaitMode wait_mode = wait_by_fifo,
const Type type = binary,
const Priority priority = no_priority_inherit,
const Ceiling ceiling = no_priority_ceiling,
const rtems_task_priority priority_ceiling = 0);
// connect to an existing semaphore object by name
rtemsSemaphore(const char *name, const rtems_unsigned32 node);
// attach this object to an other objects semaphore
rtemsSemaphore(const rtemsSemaphore& semaphore);
rtemsSemaphore();
// only the creator's destructor will delete the actual object
virtual ~rtemsSemaphore();
// create or destroy (delete) a semaphore
virtual const rtems_status_code create(const char* name,
const Scope scope = local,
const rtems_unsigned32 counter = 1,
const WaitMode wait_mode = wait_by_fifo,
const Type type = binary,
const Priority priority = no_priority_inherit,
const Ceiling ceiling = no_priority_ceiling,
const rtems_task_priority priority_ceiling = 0);
virtual const rtems_status_code destroy();
// connect to an existing semaphore object, will not be the owner
const rtemsSemaphore& operator=(const rtemsSemaphore& semaphore);
virtual const rtems_status_code connect(const char *name, rtems_unsigned32 node);
// obtain the semaphore, timeout is in micro-seconds
inline const rtems_status_code obtain(bool wait = true,
const rtems_unsigned32 micro_secs = RTEMS_NO_TIMEOUT);
// release the semaphore, blocks threads eligble
inline const rtems_status_code release();
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
private:
// make the object reference no valid RTEMS object
void make_invalid();
// semaphore name
rtems_name name;
char name_str[5];
// owner, true if this object owns the semaphore
// will delete the semaphore when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
};
const rtems_status_code rtemsSemaphore::obtain(const bool wait,
const rtems_unsigned32 micro_secs)
{
rtems_interval usecs =
micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
_TOD_Microseconds_per_tick : micro_secs;
return
set_status_code(rtems_semaphore_obtain(id,
wait ? RTEMS_WAIT : RTEMS_NO_WAIT,
TOD_MICROSECONDS_TO_TICKS(usecs)));
}
const rtems_status_code rtemsSemaphore::release(void)
{
return set_status_code(rtems_semaphore_release(id));
}
#endif // _rtemsSemaphore_h_
@@ -0,0 +1,57 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsStatusCode controls and manages status codes from the RTEMS kernel.
------------------------------------------------------------------------
*/
#if !defined(_rtemsStatusCode_h_)
#define _rtemsStatusCode_h_
#include <rtems.h>
/* ----
rtemsStatusCode
*/
class rtemsStatusCode
{
public:
rtemsStatusCode() { last_status = RTEMS_NOT_CONFIGURED; }
const bool successful() { return last_status == RTEMS_SUCCESSFUL; }
const bool unsuccessful() { return last_status != RTEMS_SUCCESSFUL; }
// return the last status code
const rtems_status_code last_status_code() { return last_status; }
// return the last status as a string
const char *last_status_string();
const char *status_string(rtems_status_code status_code);
protected:
const rtems_status_code set_status_code(const rtems_status_code status)
{ return (last_status = status); }
private:
// public at the moment, this might change
rtems_status_code last_status;
};
#endif // _rtemsStatusCode_h_
+171
View File
@@ -0,0 +1,171 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsTask class.
This class allows the user to create a RTEMS task, or to access and
manage an already existing task.
The first constructor with the task parameters creates a RTEMS task
object. The destructor of this object also deletes the task
object. The last status code should be checked after construction to
see if the create completed successfully.
The second constructor connects to an existing task object. The last
status code should be checked after construction to see if the
task existed.
The third constructor is a copy constructor. Connects to an existing
object which is in scope.
The RTEMS id is set to self in the default construction.
The creation of the task object can be defered until after
construction. This allows for static task objects to be created.
RTEMS should be initialised before static constructors run, how-ever
threads will will not. You need to watch the start-order.
A task object can change state from an owner of a task to being
connected to a task.
Task objects connected to another task do not receive notification
when the task connected to changes state.
The sleep methods operate on the current thread not the task
reference by this object.
Mode control is through the rtemsTaskMode class.
The rtemsTask class reserved notepad register 31.
------------------------------------------------------------------------ */
#if !defined(_rtemsTask_h_)
#define _rtemsTask_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTask
*/
class rtemsTask
: public rtemsStatusCode
{
public:
enum FloatingPoint { fpoff = RTEMS_NO_FLOATING_POINT,
fpon = RTEMS_FLOATING_POINT };
enum Scope { local = RTEMS_LOCAL,
global = RTEMS_GLOBAL };
// only the first 4 characters of the name are taken
// creates a task
rtemsTask(const char* name,
const rtems_task_priority initial_priority,
const rtems_unsigned32 stack_size,
const rtems_mode preemption = RTEMS_NO_PREEMPT,
const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
const rtems_mode asr = RTEMS_NO_ASR,
const rtems_interrupt_level interrupt_level = 0,
const FloatingPoint floating_point = fpoff,
const Scope scope = local);
// connects to a task
rtemsTask(const char *name, const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// copy and default constructors
rtemsTask(const rtemsTask& task);
rtemsTask();
// only the creator's destructor will delete the actual object
virtual ~rtemsTask();
// create or destroy (delete) the task
virtual const rtems_status_code create(const char* name,
const rtems_task_priority initial_priority,
const rtems_unsigned32 stack_size,
const rtems_mode preemption = RTEMS_NO_PREEMPT,
const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
const rtems_mode asr = RTEMS_NO_ASR,
const rtems_interrupt_level interrupt_level = 0,
const FloatingPoint floating_point = fpoff,
const Scope scope = local);
virtual const rtems_status_code destroy();
// connect to an existing task object, will not be the owner
const rtemsTask& operator=(const rtemsTask& task);
virtual const rtems_status_code connect(const char *name,
const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
// run control
virtual const rtems_status_code start(const rtems_task_argument argument);
virtual const rtems_status_code restart(const rtems_task_argument argument);
virtual const rtems_status_code suspend();
virtual const rtems_status_code resume();
// sleep control, the timeout is in micro-seconds
virtual const rtems_status_code wake_after(const rtems_interval micro_secs);
virtual const rtems_status_code wake_when(const rtems_time_of_day& tod);
// priority control
const rtems_status_code get_priority(rtems_task_priority& priority);
const rtems_status_code set_priority(const rtems_task_priority priority);
const rtems_status_code set_priority(const rtems_task_priority priority,
rtems_task_priority& old_priority);
// notepad control
const rtems_status_code get_note(const rtems_unsigned32 notepad,
rtems_unsigned32& note);
const rtems_status_code set_note(const rtems_unsigned32 notepad,
const rtems_unsigned32 note);
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
protected:
// task entry point
virtual void body(rtems_task_argument argument);
private:
// make the object to point to RTEMS_SELF
void make_self();
// task name
rtems_name name;
char name_str[5];
// owner, true if this object owns the task
// will delete the task when it destructs
bool owner;
// the rtems id, object handle
rtems_id id;
// the argument for the task, this class uses the actual argument
// passed to RTEMS
rtems_task_argument argument;
// common entry point to the task
static rtems_task origin(rtems_task_argument argument);
};
#endif // _rtemsTask_h_
+210
View File
@@ -0,0 +1,210 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsTaskMode class.
This class allows the user to query or change the mode of an RTEMS
task.
This object only operates on the currently executing task.
The standard flags defined in RTEMS are used.
Methods are provided to operate on a group of modes which are
required to be changed in a single operation. The mode and mask is
specified by ORing the required flags.
Methods are provided for accessing and controlling a specific
mode. The returned value will only contain the requested mode's flags,
and only the that mode will be changed when setting a mode.
------------------------------------------------------------------------ */
#if !defined(_rtemsTaskMode_h_)
#define _rtemsTaskMode_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTaskMode
*/
class rtemsTaskMode
: public rtemsStatusCode
{
public:
rtemsTaskMode() {};
// group mode control, OR the values together
inline const rtems_status_code get_mode(rtems_mode& mode);
inline const rtems_status_code set_mode(const rtems_mode mode,
const rtems_mode mask);
inline const rtems_status_code set_mode(const rtems_mode mode,
const rtems_mode mask,
rtems_mode& old_mode);
// preemption control
inline const rtems_status_code get_preemption_state(rtems_mode& preemption);
inline const rtems_status_code set_preemption_state(const rtems_mode preemption);
inline const rtems_status_code set_preemption_state(const rtems_mode preemption,
rtems_mode& old_preemption);
inline const boolean preemption_set(const rtems_mode preemption);
// timeslice control
inline const rtems_status_code get_timeslice_state(rtems_mode& timeslice);
inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice);
inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice,
rtems_mode& old_timeslice);
inline const boolean timeslice_set(const rtems_mode preemption);
// async-sub-routine control
inline const rtems_status_code get_asr_state(rtems_mode& asr);
inline const rtems_status_code set_asr_state(const rtems_mode asr);
inline const rtems_status_code set_asr_state(const rtems_mode asr,
rtems_mode& old_asr);
inline const boolean asr_set(const rtems_mode preemption);
// interrupt mask control
inline const rtems_status_code get_interrupt_level(rtems_interrupt_level& level);
inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level);
inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level,
rtems_interrupt_level& old_level);
};
const rtems_status_code rtemsTaskMode::get_mode(rtems_mode& mode)
{
return set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
}
const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
const rtems_mode mask)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(mode, mask, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
const rtems_mode mask,
rtems_mode& old_mode)
{
return set_status_code(rtems_task_mode(mode, mask, &old_mode));
}
const rtems_status_code rtemsTaskMode::get_preemption_state(rtems_mode& preemption)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &preemption));
preemption &= RTEMS_PREEMPT_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption,
rtems_mode& old_preemption)
{
set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_preemption));
old_preemption &= RTEMS_PREEMPT_MASK;
return last_status_code();
}
const boolean rtemsTaskMode::preemption_set(const rtems_mode preemption)
{
return (preemption & RTEMS_PREEMPT_MASK) ? false : true;
}
const rtems_status_code rtemsTaskMode::get_timeslice_state(rtems_mode& timeslice)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &timeslice));
timeslice &= RTEMS_TIMESLICE_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice,
rtems_mode& old_timeslice)
{
set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_timeslice));
old_timeslice &= RTEMS_TIMESLICE_MASK;
return last_status_code();
}
const boolean rtemsTaskMode::timeslice_set(const rtems_mode timeslice)
{
return (timeslice & RTEMS_TIMESLICE_MASK) ? true : false;
}
const rtems_status_code rtemsTaskMode::get_asr_state(rtems_mode& asr)
{
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &asr));
asr &= RTEMS_ASR_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr,
rtems_mode& old_asr)
{
set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_asr));
old_asr &= RTEMS_ASR_MASK;
return last_status_code();
}
const boolean rtemsTaskMode::asr_set(const rtems_mode asr)
{
return (asr & RTEMS_ASR_MASK) ? true : false;
}
const rtems_status_code rtemsTaskMode::get_interrupt_level(rtems_interrupt_level& level)
{
rtems_mode mode;
set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
level = mode & RTEMS_INTERRUPT_MASK;
return last_status_code();
}
const rtems_status_code rtemsTaskMode::set_interrupt_level(const rtems_interrupt_level level)
{
rtems_mode old_mode;
return set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_mode));
}
const rtems_status_code rtemsTaskMode::set_interrupt_level(rtems_interrupt_level level,
rtems_interrupt_level& old_level)
{
set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_level));
old_level = old_level & RTEMS_INTERRUPT_MASK;
return last_status_code();
}
#endif // _rtemsTaskMode_h_
+145
View File
@@ -0,0 +1,145 @@
/*
------------------------------------------------------------------------
$Id$
------------------------------------------------------------------------
COPYRIGHT (c) 1997
Objective Design Systems Ltd Pty (ODS)
All rights reserved (R) Objective Design Systems Ltd Pty
The license and distribution terms for this file may be found in the
file LICENSE in this distribution or at
http://www.OARcorp.com/rtems/license.html.
------------------------------------------------------------------------
rtemsTimer class.
This class allows the user to create a RTEMS timer.
The trigger method is called when the timer expires. The method is
called using the thread which calls the RTEMS 'rtems_clock_tick'
method.
Timers are always local to a node.
------------------------------------------------------------------------ */
#if !defined(_rtemsTimer_h_)
#define _rtemsTimer_h_
#include <rtems++/rtemsStatusCode.h>
/* ----
rtemsTimer
*/
class rtemsTimer
: public rtemsStatusCode
{
public:
// only the first 4 characters of the name are taken,
// create a timer object
rtemsTimer(const char* name);
rtemsTimer();
// destroies the actual object
virtual ~rtemsTimer();
// create or destroy (delete) the timer
virtual const rtems_status_code create(const char* name);
virtual const rtems_status_code destroy();
// timer control
inline const rtems_status_code fire_after(const rtems_interval micro_secs);
inline const rtems_status_code repeat_fire_at(const rtems_interval micro_secs);
inline const rtems_status_code fire_when(const rtems_time_of_day& when);
inline const rtems_status_code cancel();
inline const rtems_status_code reset();
// object id, and name
const rtems_id id_is() const { return id; }
const rtems_name name_is() const { return name; }
const char *name_string() const { return name_str; }
protected:
// triggered method is called when the timer fires
virtual void triggered() = 0;
private:
// not permitted
rtemsTimer(const rtemsTimer& timer);
rtemsTimer& operator=(const rtemsTimer& timer);
// make this object reference an invalid RTEMS object
void make_invalid();
// semaphore name
rtems_name name;
char name_str[5];
// repeat true restart the timer when it fires
bool repeat;
// the rtems id, object handle
rtems_id id;
// common timer handler
static void common_handler(rtems_id id, void *user_data);
};
const rtems_status_code rtemsTimer::fire_after(const rtems_interval micro_secs)
{
repeat = false;
rtems_interval usecs =
micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
_TOD_Microseconds_per_tick : micro_secs;
return set_status_code(rtems_timer_fire_after(id,
TOD_MICROSECONDS_TO_TICKS(usecs),
common_handler,
this));
}
const rtems_status_code rtemsTimer::repeat_fire_at(const rtems_interval micro_secs)
{
repeat = true;
rtems_interval usecs =
micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
_TOD_Microseconds_per_tick : micro_secs;
return set_status_code(rtems_timer_fire_after(id,
TOD_MICROSECONDS_TO_TICKS(usecs),
common_handler,
this));
}
const rtems_status_code rtemsTimer::fire_when(const rtems_time_of_day& when)
{
return set_status_code(rtems_timer_fire_when(id,
(rtems_time_of_day*) &when,
common_handler,
this));
}
const rtems_status_code rtemsTimer::cancel()
{
repeat = false;
return set_status_code(rtems_timer_cancel(id));
}
const rtems_status_code rtemsTimer::reset()
{
return set_status_code(rtems_timer_reset(id));
}
#endif // _rtemsTimer_h_
@@ -0,0 +1,19 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/directory.cfg
SRCS=README
all: $(SRCS)
# wrapup is the one that actually builds and installs the library
# from the individual .rel files built in other directories
SUB_DIRS=include start302 startup clock console timer wrapup
+81
View File
@@ -0,0 +1,81 @@
#
# $Id$
#
BSP NAME: ods68302
BOARD: proprietary (see below for relevant information)
BUS: none
CPU FAMILY: MC68000
COPROCESSORS: 68302 communications co-processor
MODE: not applicable
DEBUG MONITOR: gdb
PERIPHERALS
===========
TIMERS: two 68302 timers, one 68302 watchdog timer
RESOLUTION: ?
SERIAL PORTS: three 68302 SCCs
REAL-TIME CLOCK:
DMA: built-in 68302, not used
VIDEO: none
SCSI: none
NETWORKING: none
DRIVER INFORMATION
==================
CLOCK DRIVER: 68302 (TIMER1)
IOSUPP DRIVER: 68302 SCC2
SHMSUPP: none
TIMER DRIVER: 68302 TIMER2
STDIO
=====
PORT: SCC3 for ROM build, SCC1 for DEGUB build
ELECTRICAL: EIA-232
BAUD: 9600
BITS PER CHARACTER: 8
PARITY: None
STOP BITS: 1
DEBUG MONITOR
=============
PORT: SCC3
ELECTRICAL: EIA-232
BAUD: 57600
BITS PER CHARACTER: 8
PARITY: None
STOP BITS: 1
NOTES
=====
This BSP is based on the gen68302. The main differences are C code for
boot parameters, the gdb monitor, and variant support.
The boot code which changes is written in C and the parameters used to
control the configuration of the chip select registers and parallel
ports are held in variant specific header files. These file also
control the other hardware specific definitions such the processor
freqency.
The gdb monitor currently uses two serial ports. One for the debugger
and one for stdio. This is costly in terms of the 68302 processor.
The build configuration contains the memory map. The bsp code does not
contain any memory map parameters. That is the ods68302.cfg contains
the link addresses.
To build a version to download via gdb use the command line parameters
to make or "RTEMS_DEBUGGER=yes". This will change the memory map to
place the code, and data above the RAM used by the gdb stub.
TODO
====
1) Lower the set size of the gdb monitor. This can be made to be about
10K or RAM. The code is about 14K.
2) Add the production memory test code. This will be C and asm
code. The asm will be a faster version of the C.
+34
View File
@@ -0,0 +1,34 @@
predefines:
-D__embedded__ -Asystem(embedded)
startfile: replace
mrtems:
pg: reset.o%s
{!pg:
g: reset.o%s
{!g:
p: reset.o%s
!p: reset.o%s
}}
{!mrtems:
pg: pgcrt0%O
{!pg:
g: gcrt0%O
{!g:
p: pcrt0%O
!p: crt0%O
}}}
link: replace
mrtems: -dc -dp -N -T linkcmds%s -e start
lib: replace
mrtems: -( -lc -lrtemsall -lgcc -)
libgcc: replace
@@ -0,0 +1,53 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
PGM=${ARCH}/clock.rel
# C source names, if any, go here -- minus the .c
C_PIECES=ckinit
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
SRCS=$(C_FILES) $(H_FILES)
OBJS=$(C_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${SRCS} ${OBJS}
$(make-rel)
all: ${ARCH} $(SRCS) $(PGM)
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
install: all
@@ -0,0 +1,162 @@
/* Clock_init()
*
* This routine initializes Timer 1 for an MC68302.
* The tick frequency is 1 millisecond.
*
* Input parameters: NONE
*
* Output parameters: NONE
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <stdlib.h> /* for atexit() */
#include <bsp.h>
#include <rtems/libio.h>
#include "m68302.h"
#define CLOCK_VECTOR 137
#define TMR1_VAL ( RBIT_TMR_RST /* software reset the timer */\
| RBIT_TMR_ICLK_MASTER16 /* master clock divided by 16 */\
| RBIT_TMR_FRR /* restart timer after ref reached */\
| RBIT_TMR_ORI) /* enable interrupt when ref reached */
#define TRR1_VAL 1000 /* 1000 ticks @ 16MHz/16
* = 1 millisecond tick.
*/
/*
* Clock_driver_ticks is a monotonically increasing counter of the
* number of clock ticks since the driver was initialized.
*/
volatile rtems_unsigned32 Clock_driver_ticks;
/*
* Clock_isrs is the number of clock ISRs until the next invocation of
* the RTEMS clock tick routine. The clock tick device driver
* gets an interrupt once a millisecond and counts down until the
* length of time between the user configured microseconds per tick
* has passed.
*/
rtems_unsigned32 Clock_isrs;
void Clock_exit( void );
/*
* These are set by clock driver during its init
*/
rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor;
/*
* ISR Handler
*/
rtems_isr Clock_isr(
rtems_vector_number vector
)
{
Clock_driver_ticks += 1;
m302.reg.isr = RBIT_ISR_TIMER1; /* clear in-service bit */
m302.reg.ter1 = (RBIT_TER_REF | RBIT_TER_CAP); /* clear timer intr request */
if ( Clock_isrs == 1 ) {
rtems_clock_tick();
Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
}
else
Clock_isrs -= 1;
}
void Install_clock(
rtems_isr_entry clock_isr
)
{
Clock_driver_ticks = 0;
Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
if ( BSP_Configuration.ticks_per_timeslice ) {
set_vector( clock_isr, CLOCK_VECTOR, 1 );
m302.reg.trr1 = TRR1_VAL; /* set timer reference register */
m302.reg.tmr1 = TMR1_VAL; /* set timer mode register & enable */
/*
* Enable TIMER1 interrupts only.
*/
m302.reg.imr = RBIT_IMR_TIMER1; /* set 68302 int-mask to allow ints */
atexit( Clock_exit );
}
}
void Clock_exit( void )
{
if ( BSP_Configuration.ticks_per_timeslice ) {
/* TODO: figure out what to do here */
/* do not restore old vector */
}
}
rtems_device_driver Clock_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
Install_clock( Clock_isr );
/*
* make major/minor avail to others such as shared memory driver
*/
rtems_clock_major = major;
rtems_clock_minor = minor;
return RTEMS_SUCCESSFUL;
}
rtems_device_driver Clock_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
rtems_unsigned32 isrlevel;
rtems_libio_ioctl_args_t *args = pargp;
if (args == 0)
goto done;
/*
* This is hokey, but until we get a defined interface
* to do this, it will just be this simple...
*/
if (args->command == rtems_build_name('I', 'S', 'R', ' '))
{
Clock_isr( CLOCK_VECTOR);
}
else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
{
rtems_interrupt_disable( isrlevel );
(void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
rtems_interrupt_enable( isrlevel );
}
done:
return RTEMS_SUCCESSFUL;
}
@@ -0,0 +1,53 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
PGM=${ARCH}/console.rel
# C source names, if any, go here -- minus the .c
C_PIECES=console
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
SRCS=$(C_FILES) $(H_FILES)
OBJS=$(C_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${SRCS} ${OBJS}
$(make-rel)
all: ${ARCH} $(SRCS) $(PGM)
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
install: all
@@ -0,0 +1,221 @@
/*
* Initialize the MC68302 SCC2 for console IO board support package.
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#define GEN68302_INIT
#include <debugport.h>
#include <bsp.h>
#include <rtems/libio.h>
/* console_initialize
*
* This routine initializes the console IO driver.
*
* Input parameters: NONE
*
* Output parameters: NONE
*
* Return values:
*/
rtems_device_driver console_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
rtems_status_code status;
/* debug_port_initialise(); */
status = rtems_io_register_name(
"/dev/console",
major,
(rtems_device_minor_number) 0
);
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status);
return RTEMS_SUCCESSFUL;
}
/* is_character_ready
*
* Check to see if a character is available on the MC68302's SCC2. If so,
* then return a TRUE (along with the character). Otherwise return FALSE.
*
* Input parameters: pointer to location in which to return character
*
* Output parameters: character (if available)
*
* Return values: TRUE - character available
* FALSE - no character available
*/
rtems_boolean is_character_ready(
char *ch /* -> character */
)
{
if (debug_port_status(0))
{
ch = debug_port_in();
return TRUE;
}
return FALSE;
}
/* inbyte
*
* Receive a character from the MC68302's SCC2.
*
* Input parameters: NONE
*
* Output parameters: NONE
*
* Return values: character read
*/
char inbyte( void )
{
char ch;
while (!is_character_ready(&ch));
return ch;
}
/* outbyte
*
* Transmit a character out on the MC68302's SCC2.
* It may support XON/XOFF flow control.
*
* Input parameters:
* ch - character to be transmitted
*
* Output parameters: NONE
*/
void outbyte(
char ch
)
{
debug_port_out(ch);
}
/*
* Open entry point
*/
rtems_device_driver console_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg
)
{
return RTEMS_SUCCESSFUL;
}
/*
* Close entry point
*/
rtems_device_driver console_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg
)
{
return RTEMS_SUCCESSFUL;
}
/*
* read bytes from the serial port. We only have stdin.
*/
rtems_device_driver console_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg
)
{
rtems_libio_rw_args_t *rw_args;
char *buffer;
int maximum;
int count = 0;
rw_args = (rtems_libio_rw_args_t *) arg;
buffer = rw_args->buffer;
maximum = rw_args->count;
for (count = 0; count < maximum; count++) {
buffer[ count ] = inbyte();
if (buffer[ count ] == '\n' || buffer[ count ] == '\r') {
buffer[ count++ ] = '\n';
buffer[ count ] = 0;
break;
}
}
rw_args->bytes_moved = count;
return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED;
}
/*
* write bytes to the serial port. Stdout and stderr are the same.
*/
rtems_device_driver console_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg
)
{
int count;
int maximum;
rtems_libio_rw_args_t *rw_args;
char *buffer;
rw_args = (rtems_libio_rw_args_t *) arg;
buffer = rw_args->buffer;
maximum = rw_args->count;
for (count = 0; count < maximum; count++) {
if ( buffer[ count ] == '\n') {
outbyte('\r');
}
outbyte( buffer[ count ] );
}
rw_args->bytes_moved = maximum;
return 0;
}
/*
* IO Control entry point
*/
rtems_device_driver console_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void * arg
)
{
return RTEMS_SUCCESSFUL;
}
@@ -0,0 +1,35 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
H_FILES = $(srcdir)/bare.h $(srcdir)/bsp.h \
$(srcdir)/coverhd.h $(srcdir)/crc.h \
$(srcdir)/debugport.h \
$(srcdir)/m68302scc.h
#
# Equate files are for including from assembly preprocessed by
# gm4 or gasp. No examples are provided except for those for
# other CPUs. The best way to generate them would be to
# provide a program which generates the constants used based
# on the C equivalents.
#
EQ_FILES =
SRCS=$(H_FILES) $(EQ_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
all: $(SRCS)
$(INSTALL) -m 444 $(H_FILES) ${PROJECT_RELEASE}/include
$(INSTALL) -m 444 $(EQ_FILES) ${PROJECT_RELEASE}/include
@@ -0,0 +1,246 @@
/*****************************************************************************/
/*
$Id$
Card Definition for a bare board.
This is an example file which actually builds a BSP for a 68302 card
called an MVF (Multi-Voice-Frequency). The card is one of a range
which run in a 100Mbit voice/video/data switch used for high end
applications such as Air Traffic Control. The transport is
FDDI-2. Yes it alive and well and working in real systems.
Chip selects are programmed as required. Three are controlled in the
boot code. They are RAM, ROM, and peripherals. You can optionally
configure the other two chip selects.
SYSTEM_CLOCK - You must defined this. It is used for setting the
baud rate.
CSEL_ROM, CSEL_RAM - Must be defined, and made to be a single number
with brackets.
ROM_WAIT_STATES, RAM_WAIT_STATES - Must be defined. This sets the
speed for the ROM and RAM.
ROM and RAM size is passed on the command line. The makefile holds
them. This allows a single place to defined it. The makefile allows
them to be passed to the linker.
CSEL_1, CSEL_2 - If defined the other macros needed to define the
chip select must be defined. If not defined they are not programmed
and registers are left in the reset state.
Card Specific Devices - The MVF card uses a chip select to address a
range of peripherials (CSEL_2). These include front panel leds, and
4 digit diagnostic display device. Put what ever you need.
LED_CONTROL - If defined the boot code will set leds as it goes.
UPDATE_DISPLAY - A four digit display device will also be updated to
show the boot state.
CARD_PA, CARD_PB - The default configuration, data direction and
data must be specified.
This file allows a range of common parameters which vary from one
variant of card to another to placed in a central file.
*/
/*****************************************************************************/
#ifndef _BARE_H_
#define _BARE_H_
#if __cplusplus
extern "C"
{
#endif
/* name of the card */
#define CARD_ID "m68302-odsbare"
/* speed of the processor */
#define SYSTEM_CLOCK (15360000)
#define SCR_DEFAULT (RBIT_SCR_IPA | RBIT_SCR_HWT | RBIT_SCR_WPV | RBIT_SCR_ADC | \
RBIT_SCR_HWDEN | RBIT_SCR_HWDCN1 | RBIT_SCR_EMWS)
/* define the chip selects */
#define CSEL_ROM 0 /* token pasted so no brackets */
#define ROM_WAIT_STATES (OR_DTACK_1) /* 100nsec at 16MHz */
#define CSEL_RAM 3
#define RAM_WAIT_STATES (OR_DTACK_0) /* 70nsec at 16MHz */
/* The remaining chip selects are called 1 and 2 */
/*
#define CSEL_1 1
#define CSEL_1_BASE (0x00?00000)
#define CSEL_1_SIZE (0x00?00000)
#define CSEL_1_WAIT_STATES (OR_DTACK_1)
*/
#define CSEL_2 2
#define CSEL_2_BASE (0x00800000)
#define CSEL_2_SIZE (0x00040000)
#define CSEL_2_WAIT_STATES (OR_DTACK_EXT)
/*
* Need to define a watchdog period
*/
#define WATCHDOG_TIMEOUT_PERIOD (3000 * 2)
/*
* Console and debug port allocation, 0=SCC1, 2=SCC3
*/
#define CONSOLE_PORT 1
#define CONSOLE_BAUD SCC_9600
#define DEBUG_PORT 2
#define DEBUG_BAUD SCC_57600
/* ----
Parallel Port Configuration, and default data directions
PORT BITS - NAME , WHO , DEFAULT WHAT
------------------------------------------------------------
PPA:: 1: 0 - Serial , PERIPHERAL, -
PPA:: 7: 2 - MVF_PPA:7:2 , IO , INPUTS
PPA:: 9: 8 - Serial , PERIPHERAL, -
PPA::15:10 - MVF_PPB:15:10 , IO , INPUTS
PPB:: 1: 0 - Setup , IO , INPUTS
PPB:: 3: 2 - SYNC_HIGHWAY_1:2 , IO , INPUTS
- SYNC_HIGHWAY_2:3 , IO , INPUTS
PPB:: 4: 4 - HARDWARE_RESET:4 , IO , OUTPUT
PPB:: 6: 5 - SOFTWARE_OVERRIDE_1:6, IO , OUTPUT
- SOFTWARE_OVERRIDE_2:5, IO , OUTPUT
PPB:: 7: 7 - Watchdog , PERIPHERAL, -
PPB::11: 8 - Interrupt , PERIPHERAL, -
PPB::15:12 - Not implemented on the 68302
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
------------------------------------------------------
PACNT 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 = 0x0303
PBCNT - - - - - - - - 1 0 0 0 0 0 0 0 = 0x0080
PADDR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0x0000
PBDDR 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 = 0x0070
PADAT 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0x0000
*/
#define CARD_PA_CONFIGURATION 0x0303
#define CARD_PB_CONFIGURATION 0x0080
#define CARD_PA_DEFAULT_DIRECTIONS 0x0000
#define CARD_PB_DEFAULT_DIRECTIONS 0x0070
#define CARD_PA_DEFAULT_DATA 0x0000
#define CARD_PB_DEFAULT_DATA (HARDWARE_RESET_DISABLE | \
SOFTWARE_OVERRIDE_1_DISABLE | \
SOFTWARE_OVERRIDE_2_DISABLE)
/* these are specific to the card and are not required */
#define HARDWARE_RESET_ENABLE 0x0000
#define HARDWARE_RESET_DISABLE 0x0010
#define SOFTWARE_OVERRIDE_1_ENABLE 0x0000
#define SOFTWARE_OVERRIDE_1_DISABLE 0x0040
#define SOFTWARE_OVERRIDE_2_ENABLE 0x0000
#define SOFTWARE_OVERRIDE_2_DISABLE 0x0020
/*
* Card Specific Devices, these are not required. Add what ever you
* like here.
*/
/* Write */
#define WRITE_REGISTER_8(address, data) \
*((rtems_unsigned8 *) (address)) = ((rtems_unsigned8) (data))
#define WRITE_REGISTER_16(address, data) \
*((rtems_unsigned16 *) (address)) = ((rtems_unsigned16) (data))
#define WRITE_REGISTER_32(address, data) \
*((rtems_unsigned32 *) (address)) = ((rtems_unsigned32) (data))
/* Read */
#define READ_REGISTER_8(address, data) data = *((rtems_unsigned8 *) (address))
#define READ_REGISTER_16(address, data) data = *((rtems_unsigned16 *) (address))
#define READ_REGISTER_32(address, data) data = *((rtems_unsigned32 *) (address))
/* CS2 : Peripherials */
#define PERIPHERIALS_BASE (CSEL_2_BASE)
#define STATUS_REGISTER_BASE (PERIPHERIALS_BASE + 0x00000000)
#define PERIPHERIALS_SIZE (0x00040000)
#define LEDS_BASE (PERIPHERIALS_BASE + 0x00004000)
#define MSC_BASE (PERIPHERIALS_BASE + 0x00008000)
#define SPARE_1_BASE (PERIPHERIALS_BASE + 0x0000C000)
#define DISPLAY_BASE (PERIPHERIALS_BASE + 0x00010000)
#define PIO_INT_BASE (PERIPHERIALS_BASE + 0x00014000)
#define UART_BASE (PERIPHERIALS_BASE + 0x00018000)
#define PIA_BASE (PERIPHERIALS_BASE + 0x0001C000)
#define LED_1 0x0002
#define LED_1_GREEN 0xFFFD
#define LED_1_RED 0xFFFF
#define LED_1_OFF 0xFFFC
#define LED_2 0x0001
#define LED_2_GREEN 0xFFFE
#define LED_2_RED 0xFFFF
#define LED_2_OFF 0xFFFC
#define LED_3 0x0000
#define LED_3_GREEN 0xFFFC
#define LED_3_RED 0xFFFC
#define LED_3_OFF 0xFFFC
#define LED_4 0x0000
#define LED_4_GREEN 0xFFFC
#define LED_4_RED 0xFFFC
#define LED_4_OFF 0xFFFC
#define LED_5 0x0000
#define LED_5_GREEN 0xFFFC
#define LED_5_RED 0xFFFC
#define LED_5_OFF 0xFFFC
#define LED_6 0x0000
#define LED_6_GREEN 0xFFFC
#define LED_6_RED 0xFFFC
#define LED_6_OFF 0xFFFC
#define LED_7 0x0000
#define LED_7_GREEN 0xFFFC
#define LED_7_RED 0xFFFC
#define LED_7_OFF 0xFFFC
#define LED_8 0x0000
#define LED_8_GREEN 0xFFFC
#define LED_8_RED 0xFFFC
#define LED_8_OFF 0xFFFC
#define MAKE_LED(L1, L2, L3, L4) ((L1 & LED_1) | (L2 & LED_2) | (L3 & LED_3) | (L4 & LED_4))
#define LED_CONTROL(L1, L2, L3, L4, L5, L6, L7, L8) \
WRITE_REGISTER_16(LEDS_BASE, MAKE_LED(L1, L2, L3, L4))
/* update the display, needs a long word */
#define UPDATE_DISPLAY(LongWordPtr) \
( WRITE_REGISTER_16(DISPLAY_BASE, *(((rtems_unsigned8 *) LongWordPtr) + 3)), \
WRITE_REGISTER_16(DISPLAY_BASE + 2, *(((rtems_unsigned8 *) LongWordPtr) + 2)), \
WRITE_REGISTER_16(DISPLAY_BASE + 4, *(((rtems_unsigned8 *) LongWordPtr) + 1)), \
WRITE_REGISTER_16(DISPLAY_BASE + 6, *((rtems_unsigned8 *) LongWordPtr)) )
/* make a better test, say switches */
#if defined(GDB_MONITOR_ACTIVE)
#define GDB_RUN_MONITOR() (1 == 1)
#else
#define GDB_RUN_MONITOR() (1 == 0)
#endif
#if __cplusplus
}
#endif
#endif
@@ -0,0 +1,139 @@
/* bsp.h
*
* This include file contains all board IO definitions.
*
* XXX : put yours in here
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#ifndef __GEN68302_BSP_h
#define __GEN68302_BSP_h
#ifdef __cplusplus
extern "C" {
#endif
#include <rtems.h>
#include <console.h>
#include <iosupp.h>
#include <clockdrv.h>
#include <m68302.h>
#if defined(VARIANT)
#define __bsp_cat(x, y) x ## y
#define __bsp_xcat(x, y) __bsp_cat(x, y)
#define __bsp_str(s) #s
#define __bsp_xstr(s) __bsp_str(s)
#define __BSP_HEADER_FILE__ __bsp_xcat(VARIANT, .h)
#define __BSP_HEADER_FILE_STR__ __bsp_xstr(__BSP_HEADER_FILE__)
#include __BSP_HEADER_FILE_STR__
#endif
/*
* Define the time limits for RTEMS Test Suite test durations.
* Long test and short test duration limits are provided. These
* values are in seconds and need to be converted to ticks for the
* application.
*
*/
#define MAX_LONG_TEST_DURATION 300 /* 5 minutes = 300 seconds */
#define MAX_SHORT_TEST_DURATION 3 /* 3 seconds */
/*
* Stuff for Time Test 27
*/
#define MUST_WAIT_FOR_INTERRUPT 0
#define Install_tm27_vector( handler ) set_vector( (handler), 0, 1 )
#define Cause_tm27_intr()
#define Clear_tm27_intr()
#define Lower_tm27_intr()
/*
* Simple spin delay in microsecond units for device drivers.
* This is very dependent on the clock speed of the target.
*/
#define delay( microseconds ) \
{ register rtems_unsigned32 _delay=(microseconds); \
register rtems_unsigned32 _tmp=123; \
asm volatile( "0: \
nbcd %0 ; \
nbcd %0 ; \
dbf %1,0b" \
: "=d" (_tmp), "=d" (_delay) \
: "0" (_tmp), "1" (_delay) ); \
}
/* Constants */
#define RAM_START RAM_BASE
#define RAM_END (RAM_BASE + RAM_SIZE)
/* Structures */
#ifdef GEN68302_INIT
#undef EXTERN
#define EXTERN
#else
#undef EXTERN
#define EXTERN extern
#endif
/*
* Device Driver Table Entries
*/
/*
* NOTE: Use the standard Console driver entry
*/
/*
* NOTE: Use the standard Clock driver entry
*/
/*
* How many libio files we want
*/
#define BSP_LIBIO_MAX_FDS 20
/* miscellaneous stuff assumed to exist */
extern rtems_configuration_table BSP_Configuration;
extern m68k_isr_entry M68Kvec[]; /* vector table address */
/* functions */
void bsp_cleanup( void );
m68k_isr_entry set_vector(
rtems_isr_entry handler,
rtems_vector_number vector,
int type
);
#ifdef __cplusplus
}
#endif
#endif
/* end of include file */
@@ -0,0 +1,115 @@
/* coverhd.h
*
* This include file has defines to represent the overhead associated
* with calling a particular directive from C. These are used in the
* Timing Test Suite to ignore the overhead required to pass arguments
* to directives. On some CPUs and/or target boards, this overhead
* is significant and makes it difficult to distinguish internal
* RTEMS execution time from that used to call the directive.
* This file should be updated after running the C overhead timing
* test. Once this update has been performed, the RTEMS Time Test
* Suite should be rebuilt to account for these overhead times in the
* timing results.
*
* NOTE: If these are all zero, then the times reported include all
* all calling overhead including passing of arguments.
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#ifndef __COVERHD_h
#define __COVERHD_h
#ifdef __cplusplus
extern "C" {
#endif
#define CALLING_OVERHEAD_INITIALIZE_EXECUTIVE 14
#define CALLING_OVERHEAD_SHUTDOWN_EXECUTIVE 11
#define CALLING_OVERHEAD_TASK_CREATE 22
#define CALLING_OVERHEAD_TASK_IDENT 17
#define CALLING_OVERHEAD_TASK_START 18
#define CALLING_OVERHEAD_TASK_RESTART 15
#define CALLING_OVERHEAD_TASK_DELETE 12
#define CALLING_OVERHEAD_TASK_SUSPEND 12
#define CALLING_OVERHEAD_TASK_RESUME 12
#define CALLING_OVERHEAD_TASK_SET_PRIORITY 16
#define CALLING_OVERHEAD_TASK_MODE 15
#define CALLING_OVERHEAD_TASK_GET_NOTE 16
#define CALLING_OVERHEAD_TASK_SET_NOTE 16
#define CALLING_OVERHEAD_TASK_WAKE_WHEN 31
#define CALLING_OVERHEAD_TASK_WAKE_AFTER 11
#define CALLING_OVERHEAD_INTERRUPT_CATCH 17
#define CALLING_OVERHEAD_CLOCK_GET 32
#define CALLING_OVERHEAD_CLOCK_SET 31
#define CALLING_OVERHEAD_CLOCK_TICK 8
#define CALLING_OVERHEAD_TIMER_CREATE 13
#define CALLING_OVERHEAD_TIMER_IDENT 12
#define CALLING_OVERHEAD_TIMER_DELETE 14
#define CALLING_OVERHEAD_TIMER_FIRE_AFTER 19
#define CALLING_OVERHEAD_TIMER_FIRE_WHEN 39
#define CALLING_OVERHEAD_TIMER_RESET 12
#define CALLING_OVERHEAD_TIMER_CANCEL 12
#define CALLING_OVERHEAD_SEMAPHORE_CREATE 18
#define CALLING_OVERHEAD_SEMAPHORE_IDENT 12
#define CALLING_OVERHEAD_SEMAPHORE_DELETE 17
#define CALLING_OVERHEAD_SEMAPHORE_OBTAIN 17
#define CALLING_OVERHEAD_SEMAPHORE_RELEASE 12
#define CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE 18
#define CALLING_OVERHEAD_MESSAGE_QUEUE_IDENT 17
#define CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE 12
#define CALLING_OVERHEAD_MESSAGE_QUEUE_SEND 14
#define CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT 14
#define CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST 17
#define CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE 19
#define CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH 14
#define CALLING_OVERHEAD_EVENT_SEND 15
#define CALLING_OVERHEAD_EVENT_RECEIVE 18
#define CALLING_OVERHEAD_SIGNAL_CATCH 14
#define CALLING_OVERHEAD_SIGNAL_SEND 14
#define CALLING_OVERHEAD_PARTITION_CREATE 23
#define CALLING_OVERHEAD_PARTITION_IDENT 17
#define CALLING_OVERHEAD_PARTITION_DELETE 12
#define CALLING_OVERHEAD_PARTITION_GET_BUFFER 15
#define CALLING_OVERHEAD_PARTITION_RETURN_BUFFER 15
#define CALLING_OVERHEAD_REGION_CREATE 23
#define CALLING_OVERHEAD_REGION_IDENT 14
#define CALLING_OVERHEAD_REGION_DELETE 12
#define CALLING_OVERHEAD_REGION_GET_SEGMENT 21
#define CALLING_OVERHEAD_REGION_RETURN_SEGMENT 15
#define CALLING_OVERHEAD_PORT_CREATE 20
#define CALLING_OVERHEAD_PORT_IDENT 14
#define CALLING_OVERHEAD_PORT_DELETE 12
#define CALLING_OVERHEAD_PORT_EXTERNAL_TO_INTERNAL 18
#define CALLING_OVERHEAD_PORT_INTERNAL_TO_EXTERNAL 18
#define CALLING_OVERHEAD_IO_INITIALIZE 18
#define CALLING_OVERHEAD_IO_OPEN 18
#define CALLING_OVERHEAD_IO_CLOSE 18
#define CALLING_OVERHEAD_IO_READ 18
#define CALLING_OVERHEAD_IO_WRITE 18
#define CALLING_OVERHEAD_IO_CONTROL 18
#define CALLING_OVERHEAD_FATAL_ERROR_OCCURRED 11
#define CALLING_OVERHEAD_RATE_MONOTONIC_CREATE 13
#define CALLING_OVERHEAD_RATE_MONOTONIC_IDENT 14
#define CALLING_OVERHEAD_RATE_MONOTONIC_DELETE 12
#define CALLING_OVERHEAD_RATE_MONOTONIC_CANCEL 12
#define CALLING_OVERHEAD_RATE_MONOTONIC_PERIOD 14
#define CALLING_OVERHEAD_MULTIPROCESSING_ANNOUNCE 8
#ifdef __cplusplus
}
#endif
#endif
/* end of include file */
@@ -0,0 +1,26 @@
/*****************************************************************************/
/*
$Id$
CRC 16 Calculate Interface
*/
/*****************************************************************************/
#ifndef _CRC_H_
#define _CRC_H_
/* ----
F U N C T I O N S
*/
#if __cplusplus
extern "C"
{
#endif
rtems_unsigned16 calc_crc(void *data, rtems_unsigned32 count);
#if __cplusplus
}
#endif
#endif
@@ -0,0 +1,42 @@
/*****************************************************************************/
/*
$Id$
Debug Port Support
*/
/*****************************************************************************/
#if !defined(_DEBUGPORT_H_)
#define _DEBUGPORT_H_
#if __cplusplus
extern "C"
{
#endif
/* normall automatic, only need when re-initialising */
void debug_port_initialise(void);
unsigned char debug_port_status(const unsigned char status);
unsigned char debug_port_in(void);
void debug_port_out(const unsigned char character);
void debug_port_write(const char *buffer);
void debug_port_write_buffer(const char *buffer, unsigned int size);
void debug_port_write_hex_uint(const unsigned int value);
void debug_port_write_hex_ulong(const unsigned long value);
/*
* special banner message for CPU specific boot code,
* initialises the debug port
*/
void debug_port_banner(void);
void debug_port_printf(const char *format, ...);
#if __cplusplus
}
#endif
#endif
@@ -0,0 +1,34 @@
/*****************************************************************************/
/*
$Id$
M68302 Scc Polled Uart Support
*/
/*****************************************************************************/
#if !defined(_M68302SCC_H_)
#define _M68302SCC_H_
#if __cplusplus
extern "C"
{
#endif
#define SCC_4800 (0)
#define SCC_9600 (1)
#define SCC_19200 (2)
#define SCC_38400 (3)
#define SCC_57600 (4)
#define SCC_115700 (5)
void scc_initialise(int channel, int baud_rate, int lf_translate);
unsigned char scc_status(int channel, const unsigned char status);
unsigned char scc_in(int channel);
void scc_out(int channel, const unsigned char character);
#if __cplusplus
}
#endif
#endif
@@ -0,0 +1,68 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
PGM=${ARCH}/start302.o
ifeq ($(RTEMS_DEBUGGER),yes)
RESET_SRC = debugreset
else
RESET_SRC = reset
CFLAGS += -DGDB_MONITOR_ACTIVE
endif
# C source names, if any, go here -- minus the .c
C_PIECES=cpuboot
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
# Assembly source names, if any, go here -- minus the .s
S_PIECES=$(RESET_SRC)
S_FILES=$(S_PIECES:%=%.s)
S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
SRCS=$(C_FILES) $(H_FILES) $(S_FILES)
OBJS=$(S_O_FILES) $(C_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${OBJS}
$(make-rel)
all: ${ARCH} $(SRCS) $(OBJS) $(PGM)
$(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/lib
# Install the program(s), appending _g or _p as appropriate.
# for include files, just use $(INSTALL)
@@ -0,0 +1,133 @@
/*****************************************************************************/
/*
Boot the CPU.
Occurs in 3 phases for a 68302.
Phase 1.
Called as soon as able after reset. The BAR has been programed, and
a small stack exists in the DPRAM. All interrupts are masked, and
the processor is running in supervisor mode. No other hardware or
chip selects are active.
This phase programs the chip select registers, the parallel ports
are set into default configurations, and basic registers cleared or
reset. The leds are programmed to show the end of phase 1.
Phase 2.
This is a piece of code which is copied to DPRAM and executed. It
should not do any more thann is currently present. The return to ROM
is managed by modifing the return address. Again leds show the status.
Phase 3.
This code executes with a valid C environment. That is the data
section has been intialised and the bss section set to 0. This phase
performs any special card initialisation and then calls boot card.
$Id$
*/
/*****************************************************************************/
#include <bsp.h>
#include <m68302.h>
#include <debugport.h>
#include <crc.h>
/*
Open the address, reset all registers
*/
void boot_phase_1()
{
M302_SCR = SCR_DEFAULT;
WRITE_OR(CSEL_ROM, ROM_SIZE, ROM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_ROM, RAM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_OR(CSEL_RAM, RAM_SIZE, RAM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_RAM, ROM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(CSEL_1)
WRITE_OR(CSEL_1, CSEL_1_SIZE, CSEL_1_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_1, CSEL_1_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
#if defined(CSEL_2)
WRITE_OR(CSEL_2, CSEL_2_SIZE, CSEL_2_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_2, CSEL_2_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
m302.reg.gimr = m302.reg.ipr = m302.reg.imr = m302.reg.isr = 0;
m302.reg.simode = 0;
m302.reg.pacnt = CARD_PA_CONFIGURATION;
m302.reg.paddr = CARD_PA_DEFAULT_DIRECTIONS;
m302.reg.padat = CARD_PA_DEFAULT_DATA;
m302.reg.pbcnt = CARD_PB_CONFIGURATION;
m302.reg.pbddr = CARD_PB_DEFAULT_DIRECTIONS;
m302.reg.pbdat = CARD_PB_DEFAULT_DATA;
m302.reg.wrr = WATCHDOG_TIMEOUT_PERIOD | WATCHDOG_ENABLE;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_OFF, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
}
/*
Swap the chip select mapping for ROM and RAM
*/
void boot_phase_2(void)
{
rtems_unsigned32 stack;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
WRITE_BR(CSEL_ROM, ROM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_BR(CSEL_RAM, RAM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_GREEN, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
/* seems to want 2, looked at assember code output */
*(&stack + 2) |= ROM_BASE;
}
/*
Any pre-main initialisation, the C environment is setup, how-ever C++
static constructors have not been called, and RTEMS is not initialised.
*/
void boot_bsp();
void set_debug_traps();
void breakpoint();
void boot_phase_3(void)
{
if (GDB_RUN_MONITOR())
{
set_debug_traps();
breakpoint();
}
debug_port_banner();
/* FIXME : add RAM and ROM checks */
/* boot the bsp, what ever this means */
boot_bsp();
WATCHDOG_TRIGGER();
}
@@ -0,0 +1,107 @@
/*
* $Id$
*
* Re-written the gen68302 start-up code.
*
* Uses gas syntax only, removed the OAR asm.h.
*
* Supplies a complete vector table in ROM.
*
* Manages all vectors with seperate handlers to trap unhandled
* execptions.
*
* Uses the target specific header file to get the runtime
* configuration
*
* COPYRIGHT (c) 1996
* Objective Design Systems Pty Ltd (ODS)
*
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
* On-Line Applications Research Corporation (OAR).
* All rights assigned to U.S. Government, 1994.
*
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
*/
|
| Entry from debugger
|
.sect .text
|
| Start
|
| Entered from a hardware reset.
|
.global start | Default entry point for GNU
start:
move.w #0x2700,%sr | Disable all interrupts
|
| zero out uninitialized data area
|
zerobss:
moveal #end,%a0 | find end of .bss
moveal #bss_start,%a1 | find beginning of .bss
moveq #0,%d0
zerobss_loop:
movel %d0,%a1@+ | to zero out uninitialized
cmpal %a0,%a1
jlt zerobss_loop | loop until _end reached
movel #end,%d0 | d0 = end of bss/start of heap
addl #heap_size,%d0 | d0 = end of heap
movel %d0,stack_start | Save for brk() routine
addl #stack_size,%d0 | make room for stack
andl #0xffffffc0,%d0 | align it on 16 byte boundary
movw #0x3700,%sr | SUPV MODE,INTERRUPTS OFF!!!
movel %d0,%a7 | set master stack pointer
movel %d0,%a6 | set base pointer
jsr boot_phase_3
|
| Initialised data
|
.sect .data
.global start_frame
start_frame:
.space 4,0
.global stack_start
stack_start:
.space 4,0
|
| Uninitialised data
|
.sect .bss
.global environ
.align 2
environ:
.long 0
.global heap_size
.set heap_size,0x2000
.global stack_size
.set stack_size,0x1000
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,68 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
PGM=${ARCH}/start302.o
ifeq ($(RTEMS_DEBUGGER),yes)
RESET_SRC = debugreset
else
RESET_SRC = reset
CFLAGS += -DGDB_MONITOR_ACTIVE
endif
# C source names, if any, go here -- minus the .c
C_PIECES=cpuboot
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
# Assembly source names, if any, go here -- minus the .s
S_PIECES=$(RESET_SRC)
S_FILES=$(S_PIECES:%=%.s)
S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
SRCS=$(C_FILES) $(H_FILES) $(S_FILES)
OBJS=$(S_O_FILES) $(C_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${OBJS}
$(make-rel)
all: ${ARCH} $(SRCS) $(OBJS) $(PGM)
$(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/lib
# Install the program(s), appending _g or _p as appropriate.
# for include files, just use $(INSTALL)
@@ -0,0 +1,133 @@
/*****************************************************************************/
/*
Boot the CPU.
Occurs in 3 phases for a 68302.
Phase 1.
Called as soon as able after reset. The BAR has been programed, and
a small stack exists in the DPRAM. All interrupts are masked, and
the processor is running in supervisor mode. No other hardware or
chip selects are active.
This phase programs the chip select registers, the parallel ports
are set into default configurations, and basic registers cleared or
reset. The leds are programmed to show the end of phase 1.
Phase 2.
This is a piece of code which is copied to DPRAM and executed. It
should not do any more thann is currently present. The return to ROM
is managed by modifing the return address. Again leds show the status.
Phase 3.
This code executes with a valid C environment. That is the data
section has been intialised and the bss section set to 0. This phase
performs any special card initialisation and then calls boot card.
$Id$
*/
/*****************************************************************************/
#include <bsp.h>
#include <m68302.h>
#include <debugport.h>
#include <crc.h>
/*
Open the address, reset all registers
*/
void boot_phase_1()
{
M302_SCR = SCR_DEFAULT;
WRITE_OR(CSEL_ROM, ROM_SIZE, ROM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_ROM, RAM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_OR(CSEL_RAM, RAM_SIZE, RAM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_RAM, ROM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(CSEL_1)
WRITE_OR(CSEL_1, CSEL_1_SIZE, CSEL_1_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_1, CSEL_1_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
#if defined(CSEL_2)
WRITE_OR(CSEL_2, CSEL_2_SIZE, CSEL_2_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_2, CSEL_2_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
m302.reg.gimr = m302.reg.ipr = m302.reg.imr = m302.reg.isr = 0;
m302.reg.simode = 0;
m302.reg.pacnt = CARD_PA_CONFIGURATION;
m302.reg.paddr = CARD_PA_DEFAULT_DIRECTIONS;
m302.reg.padat = CARD_PA_DEFAULT_DATA;
m302.reg.pbcnt = CARD_PB_CONFIGURATION;
m302.reg.pbddr = CARD_PB_DEFAULT_DIRECTIONS;
m302.reg.pbdat = CARD_PB_DEFAULT_DATA;
m302.reg.wrr = WATCHDOG_TIMEOUT_PERIOD | WATCHDOG_ENABLE;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_OFF, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
}
/*
Swap the chip select mapping for ROM and RAM
*/
void boot_phase_2(void)
{
rtems_unsigned32 stack;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
WRITE_BR(CSEL_ROM, ROM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_BR(CSEL_RAM, RAM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_GREEN, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
/* seems to want 2, looked at assember code output */
*(&stack + 2) |= ROM_BASE;
}
/*
Any pre-main initialisation, the C environment is setup, how-ever C++
static constructors have not been called, and RTEMS is not initialised.
*/
void boot_bsp();
void set_debug_traps();
void breakpoint();
void boot_phase_3(void)
{
if (GDB_RUN_MONITOR())
{
set_debug_traps();
breakpoint();
}
debug_port_banner();
/* FIXME : add RAM and ROM checks */
/* boot the bsp, what ever this means */
boot_bsp();
WATCHDOG_TRIGGER();
}
@@ -0,0 +1,107 @@
/*
* $Id$
*
* Re-written the gen68302 start-up code.
*
* Uses gas syntax only, removed the OAR asm.h.
*
* Supplies a complete vector table in ROM.
*
* Manages all vectors with seperate handlers to trap unhandled
* execptions.
*
* Uses the target specific header file to get the runtime
* configuration
*
* COPYRIGHT (c) 1996
* Objective Design Systems Pty Ltd (ODS)
*
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
* On-Line Applications Research Corporation (OAR).
* All rights assigned to U.S. Government, 1994.
*
* This material may be reproduced by or for the U.S. Government pursuant
* to the copyright license under the clause at DFARS 252.227-7013. This
* notice must appear in all copies of this file and its derivatives.
*
*/
|
| Entry from debugger
|
.sect .text
|
| Start
|
| Entered from a hardware reset.
|
.global start | Default entry point for GNU
start:
move.w #0x2700,%sr | Disable all interrupts
|
| zero out uninitialized data area
|
zerobss:
moveal #end,%a0 | find end of .bss
moveal #bss_start,%a1 | find beginning of .bss
moveq #0,%d0
zerobss_loop:
movel %d0,%a1@+ | to zero out uninitialized
cmpal %a0,%a1
jlt zerobss_loop | loop until _end reached
movel #end,%d0 | d0 = end of bss/start of heap
addl #heap_size,%d0 | d0 = end of heap
movel %d0,stack_start | Save for brk() routine
addl #stack_size,%d0 | make room for stack
andl #0xffffffc0,%d0 | align it on 16 byte boundary
movw #0x3700,%sr | SUPV MODE,INTERRUPTS OFF!!!
movel %d0,%a7 | set master stack pointer
movel %d0,%a6 | set base pointer
jsr boot_phase_3
|
| Initialised data
|
.sect .data
.global start_frame
start_frame:
.space 4,0
.global stack_start
stack_start:
.space 4,0
|
| Uninitialised data
|
.sect .bss
.global environ
.align 2
environ:
.long 0
.global heap_size
.set heap_size,0x2000
.global stack_size
.set stack_size,0x1000
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,59 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@:@srcdir@/../../shared:@srcdir@/../../../shared
PGM=${ARCH}/startup.rel
# C source names, if any, go here -- minus the .c
C_PIECES=crc debugport gdb-hooks m68302scc m68k-stub memcheck trace \
bspstart bspclean sbrk setvec
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
SRCS=$(C_FILES) $(H_FILES) $(srcdir)/rom $(srcdir)/debugger
OBJS=$(C_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${SRCS} ${OBJS}
$(make-rel)
$(srcdir)/rom:
$(srcdir)/debugger:
all: ${ARCH} $(SRCS) $(PGM)
$(INSTALL) $(srcdir)/rom $(srcdir)/debugger ${PROJECT_RELEASE}/lib
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
@@ -0,0 +1,26 @@
/* bsp_cleanup()
*
* This routine normally is part of start.s and usually returns
* control to a monitor.
*
* INPUT: NONE
*
* OUTPUT: NONE
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
void bsp_cleanup( void )
{
}
@@ -0,0 +1,263 @@
/* bsp_start()
*
* This routine starts the application. It includes application,
* board, and monitor specific initialization and configuration.
* The generic CPU dependent initialization has been performed
* before this routine is invoked.
*
* INPUT: NONE
*
* OUTPUT: NONE
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <bsp.h>
#include <rtems/libio.h>
#include <libcsupport.h>
#include <string.h>
#include <fcntl.h>
#ifdef STACK_CHECKER_ON
#include <stackchk.h>
#endif
/*
* The original table from the application and our copy of it with
* some changes.
*/
extern rtems_configuration_table Configuration;
rtems_configuration_table BSP_Configuration;
rtems_cpu_table Cpu_table;
rtems_interrupt_level bsp_isr_level;
char *rtems_progname;
/* Initialize whatever libc we are using
* called from postdriver hook
*/
void bsp_libc_init()
{
extern int end;
rtems_unsigned32 heap_start;
heap_start = (rtems_unsigned32) &end;
if (heap_start & (CPU_ALIGNMENT-1))
heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
/*
* The last parameter to RTEMS_Malloc_Initialize is the "chunk"
* size which a multiple of will be requested on each sbrk()
* call by malloc(). A value of 0 indicates that sbrk() should
* not be called to extend the heap.
*/
RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
/*
* Init the RTEMS libio facility to provide UNIX-like system
* calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
* Uses malloc() to get area for the iops, so must be after malloc init
*/
rtems_libio_init();
/*
* Set up for the libc handling.
*/
if (BSP_Configuration.ticks_per_timeslice > 0)
libc_init(1); /* reentrant if possible */
else
libc_init(0); /* non-reentrant */
}
/*
* Function: bsp_pretasking_hook
* Created: 95/03/10
*
* Description:
* BSP pretasking hook. Called just before drivers are initialized.
* Used to setup libc and install any BSP extensions.
*
* NOTES:
* Must not use libc (to do io) from here, since drivers are
* not yet initialized.
*
*/
void
bsp_pretasking_hook(void)
{
bsp_libc_init();
#ifdef STACK_CHECKER_ON
/*
* Initialize the stack bounds checker
* We can either turn it on here or from the app.
*/
Stack_check_Initialize();
#endif
#ifdef RTEMS_DEBUG
rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}
/*
* After drivers are setup, register some "filenames"
* and open stdin, stdout, stderr files
*
* Newlib will automatically associate the files with these
* (it hardcodes the numbers)
*/
void
bsp_postdriver_hook(void)
{
int stdin_fd, stdout_fd, stderr_fd;
int error_code;
error_code = 'S' << 24 | 'T' << 16;
if ((stdin_fd = __rtems_open("/dev/console", O_RDONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '0' );
if ((stdout_fd = __rtems_open("/dev/console", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '1' );
if ((stderr_fd = __rtems_open("/dev/console", O_WRONLY, 0)) == -1)
rtems_fatal_error_occurred( error_code | 'D' << 8 | '2' );
if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
rtems_fatal_error_occurred( error_code | 'I' << 8 | 'O' );
}
void bsp_start()
{
/*
* Allocate the memory for the RTEMS Work Space. This can come from
* a variety of places: hard coded address, malloc'ed from outside
* RTEMS world (e.g. simulator or primitive memory manager), or (as
* typically done by stock BSPs) by subtracting the required amount
* of work space from the last physical address on the CPU board.
*/
#if 0
Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/;
#endif
/*
* Copy the Configuration Table .. so we can change it
*/
BSP_Configuration = Configuration;
/*
* Add 1 region for the RTEMS Malloc
*/
BSP_Configuration.RTEMS_api_configuration->maximum_regions++;
/*
* Add 1 extension for newlib libc
*/
#ifdef RTEMS_NEWLIB
BSP_Configuration.maximum_extensions++;
#endif
/*
* Add another extension if using the stack checker
*/
#ifdef STACK_CHECKER_ON
BSP_Configuration.maximum_extensions++;
#endif
/*
* Tell libio how many fd's we want and allow it to tweak config
*/
rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
/*
* Need to "allocate" the memory for the RTEMS Workspace and
* tell the RTEMS configuration where it is. This memory is
* not malloc'ed. It is just "pulled from the air".
*/
BSP_Configuration.work_space_start = (void *)
(RAM_END - BSP_Configuration.work_space_size);
/*
* initialize the CPU table for this BSP
*/
/*
* we do not use the pretasking_hook
*/
Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */
Cpu_table.predriver_hook = NULL;
Cpu_table.postdriver_hook = bsp_postdriver_hook;
Cpu_table.idle_task = NULL; /* do not override system IDLE task */
Cpu_table.do_zero_of_workspace = TRUE;
Cpu_table.interrupt_stack_size = 4096;
Cpu_table.extra_mpci_receive_server_stack = 0;
/*
* Don't forget the other CPU Table entries.
*/
/*
* Start RTEMS
*/
bsp_isr_level = rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table );
}
int main(int argc, char **argv, char **environ)
{
if ((argc > 0) && argv && argv[0])
rtems_progname = argv[0];
else
rtems_progname = "RTEMS";
rtems_initialize_executive_late( bsp_isr_level );
bsp_cleanup();
return 0;
}
void boot_bsp()
{
/* the atexit hook will be before the static destructor list's entry
point */
bsp_start();
exit(main(0, 0, 0));
}
@@ -0,0 +1,133 @@
/*****************************************************************************/
/*
Boot the CPU.
Occurs in 3 phases for a 68302.
Phase 1.
Called as soon as able after reset. The BAR has been programed, and
a small stack exists in the DPRAM. All interrupts are masked, and
the processor is running in supervisor mode. No other hardware or
chip selects are active.
This phase programs the chip select registers, the parallel ports
are set into default configurations, and basic registers cleared or
reset. The leds are programmed to show the end of phase 1.
Phase 2.
This is a piece of code which is copied to DPRAM and executed. It
should not do any more thann is currently present. The return to ROM
is managed by modifing the return address. Again leds show the status.
Phase 3.
This code executes with a valid C environment. That is the data
section has been intialised and the bss section set to 0. This phase
performs any special card initialisation and then calls boot card.
$Id$
*/
/*****************************************************************************/
#include <bsp.h>
#include <m68302.h>
#include <debugport.h>
#include <crc.h>
/*
Open the address, reset all registers
*/
void boot_phase_1()
{
M302_SCR = SCR_DEFAULT;
WRITE_OR(CSEL_ROM, ROM_SIZE, ROM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_ROM, RAM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_OR(CSEL_RAM, RAM_SIZE, RAM_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_RAM, ROM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(CSEL_1)
WRITE_OR(CSEL_1, CSEL_1_SIZE, CSEL_1_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_1, CSEL_1_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
#if defined(CSEL_2)
WRITE_OR(CSEL_2, CSEL_2_SIZE, CSEL_2_WAIT_STATES, OR_MASK_RW, OR_MASK_FC);
WRITE_BR(CSEL_2, CSEL_2_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#endif
m302.reg.gimr = m302.reg.ipr = m302.reg.imr = m302.reg.isr = 0;
m302.reg.simode = 0;
m302.reg.pacnt = CARD_PA_CONFIGURATION;
m302.reg.paddr = CARD_PA_DEFAULT_DIRECTIONS;
m302.reg.padat = CARD_PA_DEFAULT_DATA;
m302.reg.pbcnt = CARD_PB_CONFIGURATION;
m302.reg.pbddr = CARD_PB_DEFAULT_DIRECTIONS;
m302.reg.pbdat = CARD_PB_DEFAULT_DATA;
m302.reg.wrr = WATCHDOG_TIMEOUT_PERIOD | WATCHDOG_ENABLE;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_OFF, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
}
/*
Swap the chip select mapping for ROM and RAM
*/
void boot_phase_2(void)
{
rtems_unsigned32 stack;
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_RED, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
WRITE_BR(CSEL_ROM, ROM_BASE, BR_READ_ONLY, BR_FC_NULL, BR_ENABLED);
WRITE_BR(CSEL_RAM, RAM_BASE, BR_READ_WRITE, BR_FC_NULL, BR_ENABLED);
#if defined(LED_CONTROL)
LED_CONTROL(LED_1_GREEN, LED_2_RED, LED_3_OFF, LED_4_OFF,
LED_5_OFF, LED_6_OFF, LED_7_OFF, LED_8_OFF);
#endif
/* seems to want 2, looked at assember code output */
*(&stack + 2) |= ROM_BASE;
}
/*
Any pre-main initialisation, the C environment is setup, how-ever C++
static constructors have not been called, and RTEMS is not initialised.
*/
void boot_bsp();
void set_debug_traps();
void breakpoint();
void boot_phase_3(void)
{
if (GDB_RUN_MONITOR())
{
set_debug_traps();
breakpoint();
}
debug_port_banner();
/* FIXME : add RAM and ROM checks */
/* boot the bsp, what ever this means */
boot_bsp();
WATCHDOG_TRIGGER();
}
@@ -0,0 +1,88 @@
/*****************************************************************************/
/*
$Id$
CRC 16 Calculation
This module calculates the CRC-16.
*/
/*****************************************************************************/
#include "bsp.h"
#include "m68302.h"
#include "crc.h"
/* ----
C O N S T A N T S
*/
static const rtems_unsigned16 factor[] =
{
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
/*
MACRO : calculates a CRC byte wise
*/
#define NEW_CRC(byte, crc) factor[(byte) ^ ((crc) & 0xFF)] ^ (((crc) >> 8) & 0xFF)
/* ----
CalcCRC
Calculates the CRC value of a block of memory
*/
rtems_unsigned16 calc_crc(void* vdata, /* pointer to memory block */
rtems_unsigned32 count) /* length of block in bytes */
{
register rtems_unsigned8 *data = vdata;
register rtems_unsigned16 crc;
register rtems_unsigned32 byte;
/* initialise to either 0x0 or 0xffff depending on the
CRC implementation */
crc = 0;
for (byte = count; byte > 0; byte--)
{
WATCHDOG_TOGGLE();
crc = NEW_CRC(*data++, crc);
}
return crc;
}
@@ -0,0 +1,54 @@
/*
* $Id$
*
* MC68302 Linker command file
*
*/
SECTIONS
{
.text . :
{
text_start = .;
*(.text)
etext = .;
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
. = ALIGN(4);
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
}
.vtable (ADDR(.text) + SIZEOF(.text)) :
{
vtable_start = .;
*(.vtable)
evtable = .;
}
.data (ADDR(.vtable) + SIZEOF(.vtable)) :
{
data_start = .;
*(.data)
edata = .;
}
.bss (ADDR(.data) + SIZEOF(.data)) :
{
bss_start = .;
*(.bss)
*(COMMON)
end = . ;
_end = . ;
}
}
m302 = MC68302_BASE;
_VBR = 0; /* location of the VBR table (in RAM) */
ENTRY(start);
@@ -0,0 +1,163 @@
/*****************************************************************************/
/*
High Level Debug Port Functions
$Id$
*/
/*****************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include "debugport.h"
#include "m68302scc.h"
#include "bsp.h"
static int initialised;
void debug_port_initialise(void)
{
scc_initialise(CONSOLE_PORT, CONSOLE_BAUD, FALSE);
#if defined(DEBUG_PORT)
scc_initialise(DEBUG_PORT, DEBUG_BAUD, FALSE);
#endif
}
unsigned char debug_port_status(const unsigned char status)
{
if (!initialised)
{
initialised = 1;
debug_port_initialise();
}
return scc_status(CONSOLE_PORT, status);
}
unsigned char debug_port_in(void)
{
if (!initialised)
{
initialised = 1;
debug_port_initialise();
}
return scc_in(CONSOLE_PORT);
}
void debug_port_out(const unsigned char character)
{
if (!initialised)
{
initialised = 1;
debug_port_initialise();
}
scc_out(CONSOLE_PORT, character);
}
void debug_port_write(const char *buffer)
{
while (*buffer != '\0')
{
debug_port_out(*buffer++);
}
}
void debug_port_write_buffer(const char *buffer, unsigned int size)
{
unsigned int count;
for (count = 0; count < size; count++)
{
debug_port_out(buffer[count]);
}
}
void debug_port_write_hex_uint(const unsigned int value)
{
unsigned int bits = sizeof(value) * 8;
unsigned char c;
do
{
bits -= 4;
c = (unsigned char) ((value >> bits) & 0x0F);
if (c < 10)
{
c += '0';
}
else
{
c += 'a' - 10;
}
debug_port_out((char) c);
}
while (bits);
}
void debug_port_write_hex_ulong(const unsigned long value)
{
unsigned int bits = sizeof(value) * 8;
unsigned char c;
do
{
bits -= 4;
c = (unsigned char) ((value >> bits) & 0x0F);
if (c < 10)
{
c += '0';
}
else
{
c += 'a' - 10;
}
debug_port_out((char) c);
}
while (bits);
}
#define BUFFER_SIZE (256)
static char buffer[BUFFER_SIZE];
void debug_port_printf(const char *format, ...)
{
va_list args;
int written;
/* gain access to the argument list */
va_start(args, format);
/* set the trap */
buffer[BUFFER_SIZE - 2] = '\xAA';
buffer[BUFFER_SIZE - 1] = '\x55';
/* format the string and send to stdout */
written = vsprintf(buffer, format, args);
/* try an trap format buffer overflows */
if ((buffer[BUFFER_SIZE - 2] != '\xAA') ||
(buffer[BUFFER_SIZE - 1] != '\x55'))
{
debug_port_write("debug port buffer overflow, halting...");
DISABLE_WATCHDOG();
while (1 == 1);
}
/* see if an error occurred, if not flush the output buffer */
if (written != -1)
{
debug_port_write_buffer(buffer, written);
}
}
void debug_port_banner(void)
{
#define CARD_LABEL "ods68302-" #VARIANT
debug_port_write("\n\n\r");
debug_port_write(_Copyright_Notice);
debug_port_write("\n\r " CARD_ID "\n\r");
}
@@ -0,0 +1,76 @@
/*****************************************************************************/
/*
$Id$
Hooks for GDB
*/
/*****************************************************************************/
#include <bsp.h>
#include <m68302.h>
#include <m68302scc.h>
static int initialised = 0;
void putDebugChar(char ch)
{
if (!initialised)
{
scc_initialise(DEBUG_PORT, DEBUG_BAUD, 0);
initialised = 1;
}
scc_out(DEBUG_PORT, ch);
}
char getDebugChar(void)
{
if (!initialised)
{
scc_initialise(DEBUG_PORT, DEBUG_BAUD, 0);
initialised = 1;
}
while (!scc_status(DEBUG_PORT, 0));
return scc_in(DEBUG_PORT);
}
/*
* Need to create yet another jump table for gdb this time
*/
void (*exceptionHook)(unsigned int) = 0;
typedef struct {
rtems_unsigned16 move_a7; /* move #FORMAT_ID,%a7@- */
rtems_unsigned16 format_id;
rtems_unsigned16 jmp; /* jmp _ISR_Handlers */
rtems_unsigned32 isr_handler;
} GDB_HANDLER_ENTRY;
#if !defined(M68K_MOVE_A7)
#define M68K_MOVE_A7 0x3F3C
#endif
#if !defined(M68K_JMP)
#define M68K_JMP 0x4EF9
#endif
/* points to jsr-exception-table in targets wo/ VBR register */
static GDB_HANDLER_ENTRY gdb_jump_table[256];
void exceptionHandler(unsigned int vector, void *handler)
{
rtems_unsigned32 *interrupt_table = 0;
gdb_jump_table[vector].move_a7 = M68K_MOVE_A7;
gdb_jump_table[vector].format_id = vector;
gdb_jump_table[vector].jmp = M68K_JMP;
gdb_jump_table[vector].isr_handler = (rtems_unsigned32) handler;
interrupt_table[vector] = (rtems_unsigned32) &gdb_jump_table[vector];
}
@@ -0,0 +1,55 @@
/*
* $Id$
*
* MC68302 Linker command file
*
*/
SECTIONS
{
.text . :
{
text_start = .;
*(.text)
etext = .;
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
. = ALIGN(4);
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
}
.vtable 0 :
{
vtable_start = .;
*(.vtable)
evtable = .;
}
.data (ADDR(.vtable) + SIZEOF(.vtable)) :
AT (ADDR(.text) + SIZEOF(.text))
{
data_start = .;
*(.data)
edata = .;
}
.bss (ADDR(.data) + SIZEOF(.data)) :
{
bss_start = .;
*(.bss)
*(COMMON)
end = . ;
_end = . ;
}
}
m302 = MC68302_BASE;
_VBR = ADDR(.vtable); /* location of the VBR table (in RAM) */
@@ -0,0 +1,159 @@
/*****************************************************************************/
/*
$Id$
M68302 SCC Polled Driver
*/
/*****************************************************************************/
#include <bsp.h>
#include <m68302.h>
#include <m68302scc.h>
#define M68302_SCC_COUNT (3)
static volatile m302_SCC_t *scc[M68302_SCC_COUNT] = { 0, 0, 0 };
static volatile m302_SCC_Registers_t *scc_reg[M68302_SCC_COUNT] = { 0, 0, 0 };
static int scc_translate[M68302_SCC_COUNT] = { 0, 0, 0 };
static const rtems_unsigned16 baud_clocks[] =
{
(SYSTEM_CLOCK / ( 4800 * 16)),
(SYSTEM_CLOCK / ( 9600 * 16)),
(SYSTEM_CLOCK / ( 19200 * 16)),
(SYSTEM_CLOCK / ( 38400 * 16)),
(SYSTEM_CLOCK / ( 57600 * 16)),
(SYSTEM_CLOCK / (115700 * 16))
};
void scc_initialise(int channel, int baud, int translate)
{
rtems_unsigned16 scon;
if (channel < M68302_SCC_COUNT)
{
scc[channel] = &m302.scc1 + channel;
scc_reg[channel] = &m302.reg.scc[channel];
scc_translate[channel] = translate;
scon = (baud_clocks[baud] & 0xF800) == 0 ? 0 : 1;
scon |= (((baud_clocks[baud] / (1 + scon * 3)) - 1) << 1) & 0x0FFE;
scc_reg[channel]->scon = scon;
scc_reg[channel]->scm = 0x0171;
scc[channel]->bd.tx[0].status = 0x2000;
scc[channel]->bd.tx[0].length = 0;
scc[channel]->bd.tx[0].buffer =
(rtems_unsigned8*) &(scc[channel]->bd.tx[1].buffer);
scc[channel]->bd.rx[0].status = 0x2000;
scc[channel]->bd.rx[0].length = 0;
scc[channel]->bd.rx[0].buffer =
(rtems_unsigned8*) &(scc[channel]->bd.rx[1].buffer);
scc[channel]->parm.rfcr = 0x50;
scc[channel]->parm.tfcr = 0x50;
scc[channel]->parm.mrblr = 0x0001;
scc[channel]->prot.uart.max_idl = 0x0004;
scc[channel]->prot.uart.brkcr = 1;
scc[channel]->prot.uart.parec = 0;
scc[channel]->prot.uart.frmec = 0;
scc[channel]->prot.uart.nosec = 0;
scc[channel]->prot.uart.brkec = 0;
scc[channel]->prot.uart.uaddr1 = 0;
scc[channel]->prot.uart.uaddr2 = 0;
scc[channel]->prot.uart.character[0] = 0x0003;
scc[channel]->prot.uart.character[1] = 0x8000;
scc_reg[channel]->scce = 0xFF;
scc_reg[channel]->sccm = 0x15;
scc_reg[channel]->scm = 0x17d;
}
}
unsigned char scc_status(int channel, unsigned char status)
{
rtems_unsigned16 rx_status;
m302.reg.wcn = 0;
if ((channel < M68302_SCC_COUNT) && scc[channel])
{
rx_status = scc[channel]->bd.rx[0].status;
if ((rx_status & 0x8000) == 0)
{
if (rx_status & 0x003B)
{
return 2;
}
if (status == 0)
{
return 1;
}
}
}
return 0;
}
unsigned char scc_in(int channel)
{
m302.reg.wcn = 0;
if ((channel < M68302_SCC_COUNT) && scc[channel])
{
if ((scc[channel]->bd.rx[0].status & 0x8000) == 0)
{
unsigned char c;
c = *(scc[channel]->bd.rx[0].buffer);
scc[channel]->bd.rx[0].status = 0xa000;
return c;
}
}
return 0;
}
void scc_out(int channel, unsigned char character)
{
if ((channel < M68302_SCC_COUNT) && scc[channel])
{
do
{
m302.reg.wcn = 0;
}
while (scc[channel]->bd.tx[0].status & 0x8000);
*(scc[channel]->bd.tx[0].buffer) = character;
scc[channel]->bd.tx[0].length = 1;
scc[channel]->bd.tx[0].status = 0xa000;
if (scc_translate[channel])
{
if (character == '\n')
{
scc_out(channel, '\r');
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,33 @@
/*****************************************************************************/
/*
$Id$
Memory check routines.
The production test is a destrucive full test.
The boot test is a minimal, non-desctructive.
The partial memory test performs a scetion at a time, and gets
called in a repeated fashion to completely check the memory,
*/
/*****************************************************************************/
void
production_memory_test()
{
}
void
boot_memory_test()
{
}
void
reset_partial_memory_test()
{
}
void
partial_memory_test()
{
}
@@ -0,0 +1,56 @@
/*
* $Id$
*
* MC68302 Linker command file
*
*/
SECTIONS
{
.text . :
{
text_start = .;
*(.text)
etext = .;
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
. = ALIGN(4);
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
}
.vtable 0 :
{
vtable_start = .;
*(.vtable)
evtable = .;
}
.data (ADDR(.vtable) + SIZEOF(.vtable)) :
AT (ADDR(.text) + SIZEOF(.text))
{
data_start = .;
*(.data)
edata = .;
}
.bss (ADDR(.data) + SIZEOF(.data)) :
{
bss_start = .;
*(.bss)
*(COMMON)
end = . ;
_end = . ;
}
}
m302 = MC68302_BASE;
_VBR = 0; /* location of the VBR table (in RAM) */
@@ -0,0 +1,175 @@
/*****************************************************************************/
/*
$Id$
Trace Exception dumps a back trace to the debug serial port
*/
/*****************************************************************************/
#include <bsp.h>
#include <debugport.h>
#ifdef 0
/* FIXME : could get the string to print when in the BSP */
static const char *exception_names[] =
{
"RESET STACK TOP",
"RESET",
"BUS ERROR",
"ADDRESS ERROR",
"ILLEGAL OPCODE",
"ZERO DIVIDE",
"CHK",
"OVERFLOW",
"PRIVILEGE",
"TRACE",
"LINE 1010 EMULATOR",
"LINE 1111 EMULATOR",
"UNASSIGNED 12",
"UNASSIGNED 13",
"FORMAT ERROR",
"UNINITIALISED INTERRUPT",
"UNASSIGNED 16",
"NODE ANCHOR",
"SYSTEM ANCHOR",
"UNASSIGNED 19",
"UNASSIGNED 20",
"UNASSIGNED 21",
"UNASSIGNED 22",
"UNASSIGNED 23",
"SPURIOUS HANDLER",
"LEVEL 1",
"LEVEL 2",
"LEVEL 3",
"LEVEL 4",
"LEVEL 5",
"LEVEL 6",
"LEVEL 7",
"TRAP 0",
"TRAP 1",
"TRAP 2",
"TRAP 3",
"TRAP 4",
"TRAP 5",
"TRAP 6",
"TRAP 7",
"TRAP 8",
"TRAP 9",
"TRAP 10",
"TRAP 11",
"TRAP 12",
"TRAP 13",
"TRAP 14",
"TRAP 15"
};
#endif
void trace_exception(unsigned long d0,
unsigned long d1,
unsigned long d2,
unsigned long d3,
unsigned long d4,
unsigned long d5,
unsigned long d6,
unsigned long d7,
unsigned long a0,
unsigned long a1,
unsigned long a2,
unsigned long a3,
unsigned long a4,
unsigned long a5,
unsigned long a6,
unsigned long a7,
unsigned long sr_pch,
unsigned long pcl_format)
{
unsigned int sr = sr_pch >> 16;
unsigned long pc = (sr_pch << 16) | (pcl_format >> 16);
unsigned int format = pcl_format & 0xFFFF;
unsigned int index;
unsigned char ch;
asm volatile(" orw #0x0700,%sr");
debug_port_banner();
debug_port_write("unhandled exception=");
debug_port_write_hex_uint(format >> 2);
debug_port_write("\n");
debug_port_write("sr=");
debug_port_write_hex_uint(sr);
debug_port_write(", pc=");
debug_port_write_hex_ulong(pc);
debug_port_write("\n");
for (index = 0; index < 16; index++)
{
if (index == 8)
{
debug_port_write("\n\r");
}
if (index < 8)
{
debug_port_out('d');
debug_port_out('0' + index);
}
else
{
debug_port_out('a');
debug_port_out('0' + index - 8);
}
debug_port_out('=');
debug_port_write_hex_ulong(*(((unsigned long*) &d0) + index));
debug_port_out(' ');
}
for (index = 0; index < (16 * 10); index++)
{
if ((index % 16) == 0)
{
debug_port_write("\n");
debug_port_write_hex_ulong((unsigned long) (((char*) &index) + index));
debug_port_write(" : ");
}
else
{
debug_port_out(' ');
}
ch = (*(((char*) &index) + index) >> 4) & 0x0F;
if (ch < 10)
{
ch += '0';
}
else
{
ch += 'a' - 10;
}
debug_port_out((char) ch);
ch = *(((char*) &index) + index) & 0x0F;
if (ch < 10)
{
ch += '0';
}
else
{
ch += 'a' - 10;
}
debug_port_out((char) ch);
}
debug_port_write("\nhalting cpu...");
#if defined(UPDATE_DISPLAY)
UPDATE_DISPLAY("HALT");
#endif
WATCHDOG_TRIGGER();
while (1 == 1);
}
@@ -0,0 +1,58 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
PGM=${ARCH}/timer.rel
# C source names, if any, go here -- minus the .c
C_PIECES=timer
C_FILES=$(C_PIECES:%=%.c)
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
H_FILES=
# Assembly source names, if any, go here -- minus the .s
S_PIECES=timerisr
S_FILES=$(S_PIECES:%=%.s)
S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o)
SRCS=$(C_FILES) $(H_FILES) $(S_FILES)
OBJS=$(C_O_FILES) $(S_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
${PGM}: ${SRCS} ${OBJS}
$(make-rel)
all: ${ARCH} $(SRCS) $(PGM)
# the .rel file built here will be put into libbsp.a by ../wrapup/Makefile
install: all
@@ -0,0 +1,130 @@
/* Timer_init()
*
* This routine initializes TIMER 2 for an MC68302.
*
* Input parameters: NONE
*
* Output parameters: NONE
*
* NOTE: It is important that the timer start/stop overhead be
* determined when porting or modifying this code.
*
* COPYRIGHT (c) 1989-1997.
* On-Line Applications Research Corporation (OAR).
* Copyright assigned to U.S. Government, 1994.
*
* The license and distribution terms for this file may in
* the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#include <rtems.h>
#include <bsp.h>
#include "m68302.h"
#define TMR2_VAL 0x071b /* Timer mode register
* (section 3.5.2.1 in 68302 manual)
* 15-8: "7" prescaler divide by 8 (x+1)
* 7-6: 00 dis. intr. on capture event
* 5: 0 active-low pulse
* 4: 1 intr. on reaching reference
* 3: 1 restart counter on reference
* 2-1: 01 master clock input source
* 0: 1 enable timer
*/
#define TRR2_VAL 2000 /* Timer reference register
* (section 3.5.2.2 in 68302 manual)
* 2000 ticks @ (16MHz/1)/8 = 1-ms count
*/
rtems_unsigned32 Timer_interrupts;
rtems_boolean Timer_driver_Find_average_overhead;
rtems_isr timerisr();
void Timer_initialize( void )
{
m302.reg.tmr2 = 0; /* disable timer */
Timer_interrupts = 0; /* clear timer ISR count */
m302.reg.trr2 = TRR2_VAL; /* set timer reference register */
m302.reg.tmr2 = TMR2_VAL; /* set timer mode register */
m302.reg.imr |= RBIT_IMR_TIMER2; /* set 68302 int-mask to allow ints */
}
/*
* The following controls the behavior of Read_timer().
*
* FIND_AVG_OVERHEAD * instructs the routine to return the "raw" count.
*
* AVG_OVEREHAD is the overhead for starting and stopping the timer. It
* is usually deducted from the number returned.
*
* LEAST_VALID is the lowest number this routine should trust. Numbers
* below this are "noise" and zero is returned.
*/
#define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */
/* (Y countdowns) to start/stop the timer. */
/* This value is in microseconds. */
#define LEAST_VALID 1 /* Don't trust a clicks value lower than this */
/*
* Return timer value in 1/2-microsecond units
*/
int Read_timer( void )
{
rtems_unsigned16 clicks;
rtems_unsigned32 total;
/*
* Read the timer and see how many clicks it has been since counter
* rolled over.
*/
clicks = m302.reg.tcn2;
/*
* Total is calculated by taking into account the number of timer overflow
* interrupts since the timer was initialized and clicks since the last
* interrupts.
*/
total = (Timer_interrupts * TRR2_VAL) + clicks;
if ( Timer_driver_Find_average_overhead == 1 )
return total; /* in XXX microsecond units */
if ( total < LEAST_VALID )
return 0; /* below timer resolution */
/*
* Convert 1/2-microsecond count into microseconds
*/
return (total - AVG_OVERHEAD) >> 1;
}
/*
* Empty function call used in loops to measure basic cost of looping
* in Timing Test Suite.
*/
rtems_status_code Empty_function(void)
{
return RTEMS_SUCCESSFUL;
}
void Set_find_average_overhead(
rtems_boolean find_flag
)
{
Timer_driver_Find_average_overhead = find_flag;
}
@@ -0,0 +1,28 @@
/*
* Handle 68302 TIMER2 interrupts.
*
* All code in this routine is pure overhead which can perturb the
* accuracy of RTEMS' timing test suite.
*
* See also: Read_timer()
*
* To reduce overhead this is best to be the "rawest" hardware interupt
* handler you can write. This should be the only interrupt which can
* occur during the measured time period.
*
* An external counter, Timer_interrupts, is incremented.
*
* $Id$
*/
#include "asm.h"
BEGIN_CODE
PUBLIC(timerisr)
SYM(timerisr):
move.w #0x0040,SYM(m302)+2072 | clear interrupt in-service bit
move.b #3,SYM(m302)+2137 | clear timer interrupt event register
addq.l #1,SYM(Timer_interrupts) | increment timer value
rte
END_CODE
END
@@ -0,0 +1,48 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
BSP_PIECES=startup clock console timer
GENERIC_PIECES=
# bummer; have to use $foreach since % pattern subst rules only replace 1x
OBJS=$(foreach piece, $(BSP_PIECES), ../$(piece)/$(ARCH)/$(piece).rel) \
$(foreach piece, $(GENERIC_PIECES), ../../../$(piece)/$(ARCH)/$(piece).rel)
LIB=$(ARCH)/libbsp.a
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/lib.cfg
#
# (OPTIONAL) Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS +=
LD_PATHS +=
LD_LIBS +=
LDFLAGS +=
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS +=
CLOBBER_ADDITIONS +=
$(LIB): ${OBJS}
$(make-library)
all: ${ARCH} $(SRCS) $(LIB)
$(INSTALL_VARIANT) -m 644 $(LIB) ${PROJECT_RELEASE}/lib
+49
View File
@@ -0,0 +1,49 @@
#
# $Id$
#
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH=@srcdir@
LIBNAME=librtems++.a
LIB=${ARCH}/${LIBNAME}
# C and C++ source names, if any, go here -- minus the .c or .cc
CC_PIECES=rtemsEvent rtemsInterrupt rtemsMessageQueue rtemsSemaphore \
rtemsStatusCode rtemsTask rtemsTimer
CC_FILES=$(CC_PIECES:%=%.cc)
CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o)
SRCS=$(CC_FILES)
OBJS=$(CC_O_FILES)
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/lib.cfg
#
# Add local stuff here using +=
#
DEFINES +=
CPPFLAGS +=
CFLAGS += $(LIBC_DEFINES)
#
# Add your list of files to delete here. The config files
# already know how to delete some stuff, so you may want
# to just run 'make clean' first to see what gets missed.
# 'make clobber' already includes 'make clean'
#
CLEAN_ADDITIONS += $(LIB)
CLOBBER_ADDITIONS +=
all: ${ARCH} $(LIB)
$(INSTALL_VARIANT) -m 644 ${LIB} ${PROJECT_RELEASE}/lib
$(LIB): $(SRCS) ${OBJS}
$(make-library)

Some files were not shown because too many files have changed in this diff Show More