2013年8月4日日曜日

websocket RX63N その3

websocketでバイナリとテキストの送信と受信をやってみた。

ブラウザ等、クライアント側
プログレスバーを追加してみた。
http://www.html5.jp/library/progress.html

 <!DOCTYPE html>  
 <html>  
 <head>  
   <title>Websocket client</title>  
   <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">  
   <script src="http://code.jquery.com/jquery.js"></script>  
   <script src="../html5jp/progress.js"></script>  
 </head>  
 <body>  
   <div class="container">  
     <h1 class="page-header">Websocket client</h1>  
     <form action="" class="form-inline" id="connectForm">  
       <div class="input-append">  
         <input type="text" class="input-large" value="ws://192.168.1.63:8088/echo" id="wsServer">  
         <button class="btn" type="submit" id="connect">Connect</button>  
         <button class="btn" disabled="disabled" id="disconnect">Disconnect</button>  
       </div>  
     </form>  
     <form action="" id="sendForm">  
       <div class="input-append">  
         <input class="input-large" type="text" placeholder="message" id="message" disabled="disabled">  
         <button class="btn btn-primary" type="submit" id="send" disabled="disabled">send</button>  
       </div>  
     </form>  
     <form action="" id="ledForm">  
       <div class="input-append">  
         <button class="btn" value="1" disabled="disabled" id="led1">LED1</button>  
         <button class="btn" value="2" disabled="disabled" id="led2">LED2</button>  
       </div>  
     </form>   
     <hr>  
      <div id="sample"></div>  
     <hr>  
     <form name="mform">  
      <textarea name="messages" rows="5" cols="50"></textarea>  
     </form>  
     <hr>  
     <ul class="unstyled" id="log"></ul>  
   </div>  
   <script type="text/javascript">  
     $(document).ready(function() {  
       var ws;  
       var p = { to:50 };  
       var o = new html5jp.progress("sample",p);  
       o.draw();  
       $('#connectForm').on('submit', function() {  
         if ("WebSocket" in window) {  
           ws = new WebSocket($('#wsServer').val());  
           ws.binaryType = 'arraybuffer';  
           ws.onopen = function() {  
             $('#log').append('<li><span class="badge badge-success">websocket opened</span></li>');  
             $('#wsServer').attr('disabled', 'disabled');  
             $('#connect').attr('disabled', 'disabled');  
             $('#disconnect').removeAttr('disabled');  
             $('#led1').removeAttr('disabled');  
             $('#led2').removeAttr('disabled');  
             $('#message').removeAttr('disabled').focus();  
             $('#send').removeAttr('disabled');  
           };  
           ws.onerror = function() {  
             $('#log').append('<li><span class="badge badge-important">websocket error</span></li>');  
           };  
           ws.onmessage = function(event) {  
            if(typeof event.data == 'string') {  
            var str = "String:";  
            str += event.data;  
            var percent = parseInt(event.data);  
            if(percent != NaN){  
             o.set_val(percent);  
            }  
            } else if(typeof event.data == 'object') {  
             var byteArray = new Uint8Array(event.data);  
             var str = "Object:";  
             for( var n = 0;n < byteArray.length;n++){  
              str += " 0x" + ("0" + byteArray[n].toString(16)).slice(-2);  
             }  
            } else {  
             var str = "Unknown:";  
            }  
            var num = (document.mform.messages.value.match(/\n/g) || []).length + 1;  
            if(num > 4){  
              document.mform.messages.value = document.mform.messages.value.replace(/[\w\W]+?\n+?/,"");  
            }  
            document.mform.messages.value = document.mform.messages.value + '\r\n'+ str;  
            //$('#log').append('<li>received: <span class="badge">' + str + '</span></li>');  
           };  
           ws.onclose = function() {  
             $('#log').append('<li><span class="badge badge-important">websocket closed</span></li>');  
             $('#wsServer').removeAttr('disabled');  
             $('#connect').removeAttr('disabled');  
             $('#disconnect').attr('disabled', 'disabled');  
             $('#message').attr('disabled', 'disabled');  
             $('#send').attr('disabled', 'disabled');  
           };  
         } else {  
           $('#log').append('<li><span class="badge badge-important">WebSocket NOT supported in this browser</span></li>');  
         }  
         return false;  
       });  
       $('#sendForm').on('submit', function() {  
         var message = $('#message').val();  
         ws.send(message);  
         $('#log').append('<li>sended: <span class="badge">' + message + '</span></li>');  
         return false;  
       });  
       $('#led1').on('click', function() {  
         var buffer = new ArrayBuffer(2);  
         var byteArray = new Uint8Array(buffer);  
         byteArray[0] = 0xf8;  
         byteArray[1] = 0x01;  
         var str = "";  
         for( var n = 0; n<byteArray.length;n++){  
          str += " 0x"+ ("0" + byteArray[n].toString(16)).slice(-2);  
         }  
         ws.send(buffer);  
         var num = (document.mform.messages.value.match(/\n/g) || []).length + 1;  
         if(num > 4){  
           document.mform.messages.value = document.mform.messages.value.replace(/[\w\W]+?\n+?/,"");  
         }  
         document.mform.messages.value = document.mform.messages.value + '\r\n'+ str;  
         return false;  
       });  
       $('#led2').on('click', function() {  
         var message = $(this).attr('value');  
         ws.send(message);  
         var num = (document.mform.messages.value.match(/\n/g) || []).length + 1;  
         if(num > 4){  
            document.mform.messages.value = document.mform.messages.value.replace(/[\w\W]+?\n+?/,"");  
         }  
         document.mform.messages.value = document.mform.messages.value + '\r\n'+ message;  
         return false;  
       });  
       $('#disconnect').on('click', function() {  
         ws.close();  
         return false;  
       });  
     });  
   </script>  
 </body>  
 </html>  

RX63N側サーバー
1)受信したら、送り返す動作。
バイナリとテキストを区別しています。
2)定期的にテキストで送信。
freecounterの値
------------
 ...略
 #include "websocket.h"  
 #define BUF_LEN 512  
 void clientWorker(ID cepid);  
 /******************************************************************************  
 Exported global variables and functions (to be accessed by other files)  
 ******************************************************************************/  
 void error(const char *msg)  
 {  
      //  perror(msg);  
      return;  
      //  exit(EXIT_FAILURE);  
 }  
 int safeSend(ID cepid, const uint8_t *buffer, size_t bufferSize)  
 {  
      ER written;  
      written = tcp_snd_dat(cepid, buffer, bufferSize, 100);  
      if (written < 0) {  
           return EXIT_FAILURE;  
      }  
      return EXIT_SUCCESS;  
 }  
 static uint8_t freecounter=0;  
 void clientWorker(ID cepid)  
 {  
      uint8_t buffer[BUF_LEN];  
      uint8_t txbuffer[12];  
      int i;  
      memset(buffer, 0, BUF_LEN);  
      size_t readedLength = 0;  
      size_t frameSize = BUF_LEN;  
      enum wsState state = WS_STATE_OPENING;  
      uint8_t *data = NULL;  
      size_t dataSize = 0;  
      enum wsFrameType frameType = WS_INCOMPLETE_FRAME;  
      struct handshake hs;  
      nullHandshake(&hs);  
 #define prepareBuffer frameSize = BUF_LEN; memset(buffer, 0, BUF_LEN);  
 #define initNewFrame frameType = WS_INCOMPLETE_FRAME; readedLength = 0; memset(buffer, 0, BUF_LEN);  
      while (frameType == WS_INCOMPLETE_FRAME) {  
           ER readed = tcp_rcv_dat(cepid, buffer+readedLength, BUF_LEN-readedLength, 100);  
           if(readed == E_TMOUT){  
                readed = sprintf((char *)txbuffer,  
                     "%d",freecounter);  
                freecounter++;  
                if(freecounter > 99) freecounter = 0;  
                prepareBuffer;  
                wsMakeFrame(txbuffer, readed, buffer, &frameSize, WS_TEXT_FRAME);  
                if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                     break;  
                initNewFrame;  
                readed=0;  
           } else if (readed <= 0) {  
                return;  
           }  
           if(readed){  
                printk("(%3d)",readed);  
                for(i=0;(i<16) && (i < readed);i++){  
                     printk(" %02x",buffer[i]);       
                }  
                printk("\n");  
           }  
           readedLength+= readed;  
           if (state == WS_STATE_OPENING) {  
                frameType = wsParseHandshake(buffer, readedLength, &hs);  
           } else {  
                dataSize=0;  
                frameType = wsParseInputFrame(buffer, readedLength, &data, &dataSize);  
                if(dataSize){  
                     printk("[%3d]",dataSize);  
                     for(i=0;(i<16) && (i < dataSize);i++){  
                          printk(" %02x",data[i]);       
                     }  
                     printk("\n");  
                }  
           }  
           if ((frameType == WS_INCOMPLETE_FRAME && readedLength == BUF_LEN) || frameType == WS_ERROR_FRAME) {  
                if (frameType == WS_INCOMPLETE_FRAME)  
                     printk("buffer too small\n");  
                else  
                     printk("error in incoming frame\n");  
                if (state == WS_STATE_OPENING) {  
                     prepareBuffer;  
                     frameSize = sprintf((char *)buffer,  
                          "HTTP/1.1 400 Bad Request\r\n"  
                          "%s%s\r\n\r\n",  
                          versionField,  
                          version);  
                     safeSend(cepid, buffer, frameSize);  
                     break;  
                } else {  
                     prepareBuffer;  
                     wsMakeFrame(NULL, 0, buffer, &frameSize, WS_CLOSING_FRAME);  
                     if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                          break;  
                     state = WS_STATE_CLOSING;  
                     initNewFrame;  
                }  
           }  
           if (state == WS_STATE_OPENING) {  
                //assert(frameType == WS_OPENING_FRAME);  
                if (frameType == WS_OPENING_FRAME) {  
                     // if resource is right, generate answer handshake and send it  
                     if (strcmp(hs.resource, "/echo") != 0) {  
                          frameSize = sprintf((char *)buffer, "HTTP/1.1 404 Not Found\r\n\r\n");  
                          if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                               break;  
                     }  
                     prepareBuffer;  
                     wsGetHandshakeAnswer(&hs, buffer, &frameSize);  
                     if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                          break;  
                     state = WS_STATE_NORMAL;  
                     initNewFrame;  
                }  
           } else {  
                if (frameType == WS_CLOSING_FRAME) {  
                     if (state == WS_STATE_CLOSING) {  
                          break;  
                     } else {  
                          prepareBuffer;  
                          wsMakeFrame(NULL, 0, buffer, &frameSize, WS_CLOSING_FRAME);  
                          safeSend(cepid, buffer, frameSize);  
                          return;  
                     }  
                } else if (frameType == WS_TEXT_FRAME) {  
                     uint8_t *recievedString = NULL;  
                     recievedString = malloc(dataSize+1);  
                     //assert(recievedString);  
                     memcpy(recievedString, data, dataSize);  
                     recievedString[ dataSize ] = 0;  
                     prepareBuffer;  
                     wsMakeFrame(recievedString, dataSize, buffer, &frameSize, WS_TEXT_FRAME);  
                     if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                          break;  
                     initNewFrame;  
                } else if (frameType == WS_BINARY_FRAME) {  
                     uint8_t *recievedString = NULL;  
                     recievedString = malloc(dataSize+1);  
                     //assert(recievedString);  
                     memcpy(recievedString, data, dataSize);  
                     recievedString[ dataSize ] = 0;  
                     prepareBuffer;  
                     wsMakeFrame(recievedString, dataSize, buffer, &frameSize, WS_BINARY_FRAME);  
                     if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
                          break;  
                     initNewFrame;  
                }  
           }  
      } // read/write cycle  
 }  
 void websocket_srv(ID id)  
 {  
      ID cepid, repid;  
      ER ercd;  
      T_IPV4EP dst_addr;  
      /* setting of reception point and communucation end point */  
      cepid = id;  
      repid = id;  
      /* TCP wait connection */  
      printk("wait tcp_acp_cep\n");  
      ercd = tcp_acp_cep(cepid, repid, &dst_addr, TMO_FEVR);  
      printk("connect\n");  
      if (ercd == E_OK)  
      {  
           clientWorker(cepid);  
      }  
      /* shutdown */  
      tcp_sht_cep(cepid);  
      tcp_cls_cep(cepid, 100);  
      printk("shutdown\n");  
      return;  
 }  

2013年7月30日火曜日

websocket RX63N その2

とりあえず、勝手にRX63Nからechoクライアントへデータ送信できるようにしてみた。

2013.07.30

2013年7月29日月曜日

websocket RX63N

7/25 発売のCQ出版のInterface 誌は HTML5の特集です。
で、これをRX63Nで動作させられないかと記事を読んだのですが、わからん。

cwebsocketを発見したので、これで動作確認してみる。
http://code.google.com/p/cwebsocket/

解凍してbase64_enc.c, sha1.c, websocket.c x86_server/main.c を RX63Nのプロジェクトに組み込みます。
RX63Nのコンパイルオプションでは C99を選択します。
 tcp_main::  
 void tcp_start(void)  
 {  
      W     size;  
      ER     ercd;  
      char     ver[128];  
      printk("%s", (char*)R_t4_version.library);  
      /* start LAN controller */  
      ercd = lan_open();  
      if (ercd != E_OK)  
      {  
           printk("lan_open %08x\n",ercd);  
           while (1);  
      }  
      /* initialize TCP/IP */  
      size = tcpudp_get_ramsize();  
      if (size > (sizeof(tcpudp_work)))  
      {  
           while (1);  
      }  
      ercd = tcpudp_open(tcpudp_work);  
      if (ercd != E_OK)  
      {  
           while (1);  
      }  
 ...     略  
 config_tcpudp.c::  
 /*** Definition of TCP reception point (only port number needs to be set) ***/  
 const T_TCP_CREP tcp_crep[] =  
 {  
      /* { attribute of reception point, {local IP address, local port number}} */  
      { 0x0000, { 0, 8088 }},  
 };  
 /* Total number of TCP reception points */  
 const H __tcprepn = sizeof(tcp_crep) / sizeof(T_TCP_CREP);  
 /*** Definition of TCP communication end point  
    (only receive window size needs to be set) ***/  
 const T_TCP_CCEP tcp_ccep[] =  
 {  
      /* { attribute of TCP communication end point,  
         top address of transmit window buffer, size of transmit window buffer,  
         top address of receive window buffer, size of receive window buffer,  
         address of callback routine }  
      */  
      { 0, 0, 0, 0, 1460, 0 },  
 };  
 ...     略  
x86_server/main.c -> echo_srv.c::  
 #include "websocket.h"  
 #define BUF_LEN 512  
 void clientWorker(ID cepid);  
 /******************************************************************************  
 Exported global variables and functions (to be accessed by other files)  
 ******************************************************************************/  
 void error(const char *msg)  
 {  
   //エラー処理省き  
   return;  
 }  
 int safeSend(ID cepid, const uint8_t *buffer, size_t bufferSize)  
 {  
   ER written;  
      written = tcp_snd_dat(cepid, buffer, bufferSize, TMO_FEVR);  
   if (written < 0) {  
           tcp_sht_cep(cepid);  
           tcp_cls_cep(cepid, TMO_FEVR);  
     return EXIT_FAILURE;  
   }  
   return EXIT_SUCCESS;  
 }  
 void clientWorker(ID cepid)  
 {  
   uint8_t buffer[BUF_LEN];  
   memset(buffer, 0, BUF_LEN);  
   size_t readedLength = 0;  
   size_t frameSize = BUF_LEN;  
   enum wsState state = WS_STATE_OPENING;  
   uint8_t *data = NULL;  
   size_t dataSize = 0;  
   enum wsFrameType frameType = WS_INCOMPLETE_FRAME;  
   struct handshake hs;  
   nullHandshake(&hs);  
   #define prepareBuffer frameSize = BUF_LEN; memset(buffer, 0, BUF_LEN);  
   #define initNewFrame frameType = WS_INCOMPLETE_FRAME; readedLength = 0; memset(buffer, 0, BUF_LEN);  
   printk(" connect websocket srv\n");  
   while (frameType == WS_INCOMPLETE_FRAME) {  
     ER readed = tcp_rcv_dat(cepid, buffer+readedLength, BUF_LEN-readedLength, TMO_FEVR);  
     if (readed <= 0) {  
                tcp_sht_cep(cepid);  
                tcp_cls_cep(cepid, TMO_FEVR);  
          return;  
     }  
     readedLength+= readed;  
     //assert(readedLength <= BUF_LEN);  
           printk("readed=%d\n",readed);  
     if (state == WS_STATE_OPENING) {  
       frameType = wsParseHandshake(buffer, readedLength, &hs);  
     } else {  
       frameType = wsParseInputFrame(buffer, readedLength, &data, &dataSize);  
     }  
     if ((frameType == WS_INCOMPLETE_FRAME && readedLength == BUF_LEN) || frameType == WS_ERROR_FRAME) {  
       if (frameType == WS_INCOMPLETE_FRAME)  
         printk("buffer too small\n");  
       else  
         printk("error in incoming frame\n");  
       if (state == WS_STATE_OPENING) {  
         prepareBuffer;  
         frameSize = sprintf((char *)buffer,  
                   "HTTP/1.1 400 Bad Request\r\n"  
                   "%s%s\r\n\r\n",  
                   versionField,  
                   version);  
         safeSend(cepid, buffer, frameSize);  
         break;  
       } else {  
         prepareBuffer;  
         wsMakeFrame(NULL, 0, buffer, &frameSize, WS_CLOSING_FRAME);  
         if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
           break;  
         state = WS_STATE_CLOSING;  
         initNewFrame;  
       }  
     }  
     if (state == WS_STATE_OPENING) {  
       //assert(frameType == WS_OPENING_FRAME);  
       if (frameType == WS_OPENING_FRAME) {  
         // if resource is right, generate answer handshake and send it  
         if (strcmp(hs.resource, "/echo") != 0) {  
           frameSize = sprintf((char *)buffer, "HTTP/1.1 404 Not Found\r\n\r\n");  
           if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
             break;  
         }  
         prepareBuffer;  
         wsGetHandshakeAnswer(&hs, buffer, &frameSize);  
         if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
           break;  
         state = WS_STATE_NORMAL;  
         initNewFrame;  
       }  
     } else {  
       if (frameType == WS_CLOSING_FRAME) {  
         if (state == WS_STATE_CLOSING) {  
           break;  
         } else {  
           prepareBuffer;  
           wsMakeFrame(NULL, 0, buffer, &frameSize, WS_CLOSING_FRAME);  
           safeSend(cepid, buffer, frameSize);  
           break;  
         }  
       } else if (frameType == WS_TEXT_FRAME) {  
         uint8_t *recievedString = NULL;  
         recievedString = malloc(dataSize+1);  
         //assert(recievedString);  
         memcpy(recievedString, data, dataSize);  
         recievedString[ dataSize ] = 0;  
         prepareBuffer;  
         wsMakeFrame(recievedString, dataSize, buffer, &frameSize, WS_TEXT_FRAME);  
         if (safeSend(cepid, buffer, frameSize) == EXIT_FAILURE)  
           break;  
         initNewFrame;  
       }  
     }  
   } // read/write cycle  
      tcp_sht_cep(cepid);  
      tcp_cls_cep(cepid, TMO_FEVR);  
 }  
 void websocket_srv(ID id)  
 {  
      ID cepid, repid;  
      ER ercd;  
   T_IPV4EP dst_addr;  
      /* setting of reception point and communucation end point */  
      cepid = id;  
      repid = id;  
      /* TCP wait connection */  
      ercd = tcp_acp_cep(cepid, repid, &dst_addr, TMO_FEVR);  
      if (ercd == E_OK)  
      {  
           clientWorker(cepid);  
      }  
      /* shutdown */  
      tcp_sht_cep(cepid);  
      tcp_cls_cep(cepid, TMO_FEVR);  
      return;  
 }  
あとは htons() がないといわれたら、
 #include <machine.h>  
 #define htons(x) rev(x)  
とか

ネットで参考になった記事は
http://d.hatena.ne.jp/mzp/20110123/websokcet

2013.07.29



2013年7月26日金曜日

RX600シリーズ シリアルデバッグモニタ

http://japan.renesas.com/support/seminar/sample_program/sample_rx600/index.jsp
でシリアルデバッグモニタが公開されている。
Htermとか懐かしいな~。
2013.07.25

2013年7月24日水曜日

FreeRTOS RX63N その2

手元のGR-SAKURA に搭載されている Ethernet PHYは LAN8720 です。
このチップの LED1:LINKSTA端子は LINK/ACTIVE 表示です。
この意味は、LINK状態なら、High->LowまたはLow->High になり
ACTIVE状態(キャリア信号を検知)で、点滅となります。

ところで、 M4S-T4 Tiny のコード r_ether.c では LINK表示のみを期待してます。
したがって、以下の修正が必要とおもわれます。


 r_ether.c::  
 -  EDMAC.EESIPR.BIT.ECIIP  = 1;  
 +  EDMAC.EESIPR.BIT.ECIIP  = 0;  
 r_ether.c::R_ETHER_LinkProcess()::  
 {  
 +  uint16_t link_status=0;  
 +  link_status=Phy_GetLinkStatus();  
 +  if (link_status == R_PHY_OK && g_ether_TransferEnableFlag == ETHER_FLAG_OFF)  
 +  {  
 +       g_ether_LchngFlag=ETHER_FLAG_ON_LINK_ON;  
 +  }   
 +  if (link_status == R_PHY_ERROR && g_ether_TransferEnableFlag == ETHER_FLAG_ON)  
 +  {  
 +       g_ether_LchngFlag=ETHER_FLAG_ON_LINK_OFF;  
 +  }  
2013.07.24

2013年7月23日火曜日

FreeRTOS RX63N動作確認

FreeRTOS/RX63N に M3S-T4 Tiny TCP/IP プロトコルスタックを組み合わせた例が
http://www.renesasrtossolutions.org/jpn/
にありました。

M3S-T4 Tiny TCP/IPプロトコル・スタックについては
http://www.kumikomi.net/archives/2004/12/21tcpip1.php
に紹介されているものに類似しているように感じます。

GR-SAKURAボードで動作確認する場合の
主な変更箇所をかいてみます

hwsetup.c::ConfigurePortPins()::
    /* ==== RMII Pins setting ==== */
       /*
    Pin Functions : Port
    --------------------
    ET_MDC        : PA3
    ET_MDIO       : PA4
    ET_LINKSTA    : PA5(not use)
    RMII_RXD1     : PB0
    RMII_RXD0     : PB1
    REF50CK       : PB2
    RMII_RX_ER    : PB3
    RMII_TXD_EN   : PB4
    RMII_TXD0     : PB5
    RMII_TXD1     : PB6
    RMII_CRS_DV   : PB7
    */

    /* Clear PDR and PMR */
    PORTA.PDR.BIT.B3 = 0;
    PORTA.PDR.BIT.B4 = 0;
    PORTA.PDR.BIT.B5 = 0;
    
    PORTB.PDR.BIT.B0 = 0;
    PORTB.PDR.BIT.B1 = 0;
    PORTB.PDR.BIT.B2 = 0;
    PORTB.PDR.BIT.B3 = 0;
    PORTB.PDR.BIT.B4 = 0;
    PORTB.PDR.BIT.B5 = 0;
    PORTB.PDR.BIT.B6 = 0;
    PORTB.PDR.BIT.B7 = 0;
    
    PORTA.PMR.BIT.B3 = 0;
    PORTA.PMR.BIT.B4 = 0;
    PORTA.PMR.BIT.B5 = 0;
    
    PORTB.PMR.BIT.B0 = 0;
    PORTB.PMR.BIT.B1 = 0;
    PORTB.PMR.BIT.B2 = 0;
    PORTB.PMR.BIT.B3 = 0;
    PORTB.PMR.BIT.B4 = 0;
    PORTB.PMR.BIT.B5 = 0;
    PORTB.PMR.BIT.B6 = 0;
    PORTB.PMR.BIT.B7 = 0;

    /* Write protect off */
    MPC.PWPR.BYTE = 0x00;       /* PWPR.PFSWE write protect off */
    MPC.PWPR.BYTE = 0x40;       /* PFS register write protect off */

    /* Select pin function */
    MPC.PA3PFS.BYTE = 0x11;
    MPC.PA4PFS.BYTE = 0x11;
    MPC.PA5PFS.BYTE = 0x11;
    
    MPC.PB0PFS.BYTE = 0x12;
    MPC.PB1PFS.BYTE = 0x12;
    MPC.PB2PFS.BYTE = 0x12;
    MPC.PB3PFS.BYTE = 0x12;
    MPC.PB4PFS.BYTE = 0x12;
    MPC.PB5PFS.BYTE = 0x12;
    MPC.PB6PFS.BYTE = 0x12;
    MPC.PB7PFS.BYTE = 0x12;

    /* Write protect on */
    MPC.PWPR.BYTE = 0x80;       /* PFS register write protect on */

    /* Select ethernet mode */
    MPC.PFENET.BIT.PHYMODE = 0; /* RMII mode */

    /* Switch to the selected input/output function */
    PORTA.PMR.BIT.B3 = 1;
    PORTA.PMR.BIT.B4 = 1;
    PORTA.PMR.BIT.B5 = 1;
    
    PORTB.PMR.BIT.B0 = 1;
    PORTB.PMR.BIT.B1 = 1;
    PORTB.PMR.BIT.B2 = 1;
    PORTB.PMR.BIT.B3 = 1;
    PORTB.PMR.BIT.B4 = 1;
    PORTB.PMR.BIT.B5 = 1;
    PORTB.PMR.BIT.B6 = 1;
    PORTB.PMR.BIT.B7 = 1;
    
phy.c::
#define PHY_MII_ADDR         (0x00)

r_ether.h::
#define ETH_MODE_SEL         ETH_RMII_MODE
 here.
2013.07.23

2013年7月22日月曜日

TNKernel-RX63N Hew版

https://github.com/msalov/TNKernel-RX にあるTNKernel -RX62Nを HEWでコンパイルできないかやってみた。

HEW環境では割り込みベクタの設定を #pragma interruptで指定出来ます。
GCC では
_isr_vectors[VECT(RTC,PRD)] = rtc_irq_handler;
としたものが #pragma interrupt (rtc_irq_handler(vect=VECT(RTC,PRD)))
と出来ます。またアセンブラでは .rvector指令で
    .rvector TRAP_SAVE_SR, _tn_trap_cpu_save_sr

_tn_trap_cpu_save_sr:

    push.l    r2
とするこで C$VECTに割り込み処理先を登録してくれます。

1) tn_port_rx_gcc.S -> tn_port_rx_rxc.src
; -----------------------------------------------------------------------------
;
; TNKernel RTOS port for RX core
;
; Copyright ゥ 2011, 2012 Maxim Salov
; All rights reserved.
;
; Assembler:   GCC
;
; Permission to use, copy, modify, and distribute this software in source
; and binary forms and its documentation for any purpose and without fee
; is hereby granted, provided that the above copyright notice appear
; in all copies and that both that copyright notice and this permission
; notice appear in supporting documentation.
;
; THIS SOFTWARE IS PROVIDED BY THE YURI TIOMKIN AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL YURI TIOMKIN OR CONTRIBUTORS BE LIABLE
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
; SUCH DAMAGE.
; -----------------------------------------------------------------------------

;    .section .text

    ;; External references
    
    .glb   _tn_curr_run_task
    .glb   _tn_next_task_to_run
    .glb   _tn_system_state

    ;; Public functions declared in this file

    .glb  _tn_startup_hardware_init
    .glb  _tn_startup
    .glb  _tn_switch_context
    .glb  _tn_switch_context_exit
    .glb  _tn_switch_context_irq_handler
    .glb  _tn_trap_cpu_save_sr
    .glb  _tn_trap_cpu_restore_sr
    .glb  _tn_icpu_save_sr
    .glb  _tn_icpu_restore_sr
    .glb  _tn_cpu_save_sr
    .glb  _tn_cpu_restore_sr
    .glb  _tn_start_exe
    .glb  _tn_chk_irq_disabled
    .glb  _tn_int_exit
    .glb  _tn_cpu_int_enable
    .glb  _tn_inside_int

    ;; Addresses and bits for SWINT
    
SWINTR        .equ    000872E0h
SWINT        .equ    1
IPR03        .equ    00087303h
SWINTPR        .equ    1
IER03        .equ    00087203h
IEN3        .equ    3
IR027        .equ    0008701Bh

__stack     .equ     20000h

TN_ST_STATE_RUNNING    .equ        1
    
    ;; Bit definitions for PSW register
    
I_BIT_N        .equ    16
I_BIT        .equ    (1 << I_BIT_N)

U_BIT_N        .equ    17
U_BIT        .equ    (1 << U_BIT_N)

PM_BIT_N    .equ    20
PM_BIT    .equ        (1 << PM_BIT_N)

IPL_BITS    .equ    0F000000h

    ;; Trap numbers
    
TRAP_SAVE_SR    .equ    10
TRAP_RESTORE_SR    .equ    11

;/* ------------------------------------------------------------------------ */
    .section P,CODE
;/* ------------------------------------------------------------------------ */

;/* ------------------------------------------------------------------------ */

_tn_startup_hardware_init:

    pop    r1        ; save return address
    
    mov.l    #__stack, r2    ; get top of RAM _\stack
    mvtc    r2, isp        ; set ISP to top of RAM
    add    #-512, r2    ; reserve some space for ISP
    mvtc    r2, usp        ; set USP
    setpsw    U        ; switch to USP

    push.l    r1        ; restore return address
    
    rts
;/* ------------------------------------------------------------------------ */

_tn_startup:    
        ;; Enable SWINT (software interrupt), which is used to switch context
    mov.l    #IER03, r1
    mov.l    #IPR03, r2
     mov.l    #IR027, r3
    bclr    #IEN3, [r1].b    ; Disable SWINT
    mov.b    #SWINTPR, [r2]    ; Set SWINT priority to lowest
    mov.b    #0, [r3]    ; Reset interrupt request
    bset    #IEN3, [r1].b    ; Enable SWINT

    rts
;/* ------------------------------------------------------------------------ */

_tn_start_exe:

    ;; Interrupts must be disabled for now, but we should not trust user :/
    clrpsw    I

    ;; Set system state to TN_ST_STATE_RUNNING
    mov.l    #_tn_system_state, r1
    mov.l    #TN_ST_STATE_RUNNING, [r1]

    ;; Make request for context switch
    ;; IMHO this step is unnecessary, since we initially switch to idle task, and additional context switch will not lead us to timer task
    ;; bsr    _tn_switch_context

    ;; Reset interrupt stack pointer into initial state
    mov.l    #__stack, r1
    mvtc    r1, isp

    ;; Prepare for first context switch
    ;; Read current task pointer and write it to USP (user stack pointer)
    mov.l    #_tn_curr_run_task, r1
    mov.l    [r1], r1
    mov.l    [r1], r1
    mvtc    r1, usp
    
    ;; Restore PC and PSW from user stack and place it into interrupt stack
    setpsw    U
    popm    r1-r2
    clrpsw    U
    pushm    r1-r2

    ;; Read task context
    setpsw    U
    popm    r1-r15                        ; Restore context of new task
    ;; Switch back to interrupt stack
    clrpsw    U

    ;; "Return" from interrupt. This will fetch task's address and PSW value with already enabled interrupts, user mode and user stack pointer
    rte
    ;; We should not reach this point
?:
    bra.b  ?-

;/* ------------------------------------------------------------------------ */

_tn_switch_context_exit:

    ;; Enable interrupts
    mov.l    #1, r1
    bsr        _tn_cpu_restore_sr
    ;; Make request for context switch
    bsr        _tn_switch_context
    ;; We should not reach this point
?:
    bra.b      ?-

;/* ------------------------------------------------------------------------ */

_tn_switch_context_irq_handler_rte:

    popm    r1-r2
    rte
    
    .rvector 27, _tn_switch_context_irq_handler
    
_tn_switch_context_irq_handler:

    pushm    r1-r2
    ;; The context switching - to do or not to do, that is the question :)
    mov.l    #_tn_curr_run_task, r1
    mov.l    #_tn_next_task_to_run, r2
    mov.l    [r2], r2
    mov.l    [r1], r1                    ; If both pointers reference one task - not to do

    cmp        r1, r2
    beq.b    _tn_switch_context_irq_handler_rte
    ;; to do
    popm    r1-r2
    
    ;/* -------------------------------------- */

    ;; Save task context
    setpsw    U                        ; Switch to the stack of previous task
    pushm    r1-r15                        ; Save context

    ;; Save PC and PSW of current task (located on top of isp) into task stack (usp)
    clrpsw    U
    popm    r1-r2
    setpsw    U
    pushm    r1-r2

    ;; Prepare to save/switch/restore stack pointers
    mov.l    #_tn_curr_run_task, r1
    mov.l    [r1], r5                    ; Read TCB address of current task
    mov.l    #_tn_next_task_to_run, r2
    mov.l    [r2], r6                    ; Read TCB address of next task
    ;; Save current stack pointer
    mvfc    usp, r3
    mov.l    r3, [r5]
    ;; Set next task as current one
    mov.l    r6, [r1]
    ;; Restore stack pointer of next task
    mov.l    [r6], r3
    mvtc    r3, usp

    ;; Restore PC and PSW from user stack and place it into interrupt stack
    setpsw    U
    popm    r1-r2
    clrpsw    U
    pushm    r1-r2

    ;; Read task context
    setpsw    U
    popm    r1-r15                        ; Restore context of new task
    ;; Switch back to interrupt stack
    clrpsw    U

    ;/* -------------------------------------- */

    rte

;/* ------------------------------------------------------------------------ */

_tn_switch_context:
_tn_int_exit:

    mov.l    #SWINTR, r1
    mov.b    #SWINT, [r1]                    ; Trigger software interrupt
    rts

;/* ------------------------------------------------------------------------ */
    .rvector TRAP_SAVE_SR, _tn_trap_cpu_save_sr

_tn_trap_cpu_save_sr:

    push.l    r2

    mov.l    8[r0], r2                    ; Read PSW value from stack
    mov.l    r2, r1
    bclr    #I_BIT_N, r2                ; Reset I bit in saved PSW
    mov.l    r2, 8[r0]                    ; Store PSW value to stack

    and        #I_BIT, r1                    ; Isolate I bit

    pop        r2
    rte

;/* ------------------------------------------------------------------------ */
    .rvector TRAP_RESTORE_SR, _tn_trap_cpu_restore_sr

_tn_trap_cpu_restore_sr:

    push.l    r2

    mov.l    8[r0], r2                    ; Read PSW value from stack
    cmp        #0, r1                        ; Check if we need to set I bit
    bmnz    #I_BIT_N, r2                ; Enable/disable interrupts in saved PSW
    mov.l    r2, 8[r0]                    ; Store PSW value to stack

    pop        r2
    rte

;/* ------------------------------------------------------------------------ */

_tn_cpu_save_sr:

    int    #TRAP_SAVE_SR
    rts

;/* ------------------------------------------------------------------------ */

_tn_cpu_restore_sr:

    int    #TRAP_RESTORE_SR
    rts

;/* ------------------------------------------------------------------------ */

_tn_icpu_save_sr:

    mvfc    psw, r1
    clrpsw    I
    and        #I_BIT, r1
    rts

;/* ------------------------------------------------------------------------ */

_tn_icpu_restore_sr:

    mvfc    psw, r2
    cmp        #0, r1
    bmnz    #I_BIT_N, r2
    mvtc    r2, psw
    rts

;/* ------------------------------------------------------------------------ */

_tn_chk_irq_disabled:

    mvfc    psw, r1
    and        #I_BIT, r1                    ; Isolate I bit
    bnot    #I_BIT_N, r1                ; Invert I bit
    rts

;/* ------------------------------------------------------------------------ */

_tn_cpu_int_enable:
    ;; This function is invoked as a starting point of tn_timer_task_func.
    ;; But interrupts are already enabled, because the only way there -- to
    ;; perform context switch, that is done in SWINT.

    ;; But lets implement it any way
    mov.l    #1, r1
    bsr        _tn_cpu_restore_sr
    rts

;/* ------------------------------------------------------------------------ */

_tn_inside_int:

    mvfc    psw, r1
    and        #U_BIT, r1
    bnot    #U_BIT_N, r1
    rts

;/* ------------------------------------------------------------------------ */

    .end


2) tn_user.c
/*
TNKernel real-time kernel

Copyright ゥ 2011 Maxim Salov
All rights reserved.

Permission to use, copy, modify, and distribute this software in source
and binary forms and its documentation for any purpose and without fee
is hereby granted, provided that the above copyright notice appear
in all copies and that both that copyright notice and this permission
notice appear in supporting documentation.

THIS SOFTWARE IS PROVIDED BY THE YURI TIOMKIN AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL YURI TIOMKIN OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/

#include <iodefine.h>
#include <grsakurarx63ndef.h>
#include <tn.h>
#include <tn_user.h>
#include "sci2.h"
//----------------------------------------------------------------------------
// RTC initialization routine
//----------------------------------------------------------------------------

void rtc_init(void)
{
    /* For detailed description please refer to hardware manual */
    SYSTEM.PRCR.WORD = 0xA503;                  
    RTC.RCR3.BYTE           = 0x0c;
    SYSTEM.SOSCCR.BIT.SOSTP = 0;                         /* Enable SubClock circuit */
    SYSTEM.PRCR.WORD = 0xA500;                  

    RTC.RCR3.BIT.RTCEN      = 1;
    RTC.RCR2.BIT.START      = 0;
    while (0 != RTC.RCR2.BIT.START);
    RTC.RCR2.BIT.RESET      = 1;
    while (1 == RTC.RCR2.BIT.RESET);
    /* Set initial time and date */
    RTC.RSECCNT.BYTE        = 0;
    RTC.RMINCNT.BYTE        = 0;
    RTC.RHRCNT.BYTE         = 0;
    RTC.RDAYCNT.BYTE        = 0;
    RTC.RWKCNT.BYTE         = 0;
    RTC.RMONCNT.BYTE        = 0;
    RTC.RYRCNT.WORD         = 0x2012;
    /* Set periodic interrupt */
    RTC.RCR1.BYTE           = 0x64;
//    RTC.RCR1.BYTE           = 0xc4;
//    RTC.RCR1.BIT.PES        = 6;                             /* Set periodic interrupts frequency to 256 Hz */
//    RTC.RCR1.BIT.PIE        = 1;                             /* Enable periodic interrupts */
//    _isr_vectors[VECT(RTC,PRD)] = rtc_irq_handler;
    IR(RTC,PRD)             = 0;                             /* Clear interrupt flag */
    IPR(RTC,PRD)            = 3;                            /* Set priority level */
    IEN(RTC,PRD)            = 1;                             /* Enable interrupt in ICU */
    RTC.RCR2.BIT.START      = 1;                             /* Start RTC */
    while (1 != RTC.RCR2.BIT.START);
}

//----------------------------------------------------------------------------
// RTC periodic interrupt
//----------------------------------------------------------------------------
#pragma interrupt (rtc_irq_handler(vect=VECT(RTC,PRD)))
//interrupt_attr
void rtc_irq_handler(void)
{
    static unsigned char free_counter;
    
    free_counter++;
    if(free_counter > 63) { 
        LEDA6 ^= 1;
        free_counter=0;
    }
    tn_tick_int_processing();
    tn_int_exit();
}

//----------------------------------------------------------------------------


3)test.c
/*

  TNKernel real-time kernel - YRDKRX62N test  (RX core)

  Copyright ゥ 2011 Maxim Salov
  All rights reserved.

  Permission to use, copy, modify, and distribute this software in source
  and binary forms and its documentation for any purpose and without fee
  is hereby granted, provided that the above copyright notice appear
  in all copies and that both that copyright notice and this permission
  notice appear in supporting documentation.

  THIS SOFTWARE IS PROVIDED BY THE YURI TIOMKIN AND CONTRIBUTORS ``AS IS'' AND
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL YURI TIOMKIN OR CONTRIBUTORS BE LIABLE
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  SUCH DAMAGE.
*/

/*============================================================================
  A basic test - (Hello-LED-World)
*===========================================================================*/

#include <tn.h>
#include <machine.h>
#include <iodefine.h>
#include <grsakurarx63ndef.h>
#include "tn_user.h"
#include "hwsetup.h"
#include "sci2.h"

//----------- Tasks ----------------------------------------------------------

#define  TASK_0_PRIORITY 7
#define  TASK_1_PRIORITY 10
#define  TASK_2_PRIORITY 12

#define  TASK_0_STK_SIZE 128
#define  TASK_1_STK_SIZE 128
#define  TASK_2_STK_SIZE 128

unsigned int task_0_stack[TASK_0_STK_SIZE];
unsigned int task_1_stack[TASK_1_STK_SIZE];
unsigned int task_2_stack[TASK_2_STK_SIZE];

TN_TCB  task_0;
TN_TCB  task_1;
TN_TCB  task_2;

void task_0_func(void * par );
void task_1_func(void * par );
void task_2_func(void * par );

//----------------------------------------------------------------------------
void tcp_main(void);

void main (void)
{  
   
   HardwareSetup();
   sci2_init();
   rtc_init();

   printk("\nStart System\n");
    
   tn_start_system();

   ...以下略

4)Resetprg.c
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No 
* other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all 
* applicable laws, including copyright laws. 
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM 
* EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES 
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS 
* SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of 
* this software. By using this software, you agree to the additional terms and conditions found by accessing the 
* following link:
* http://www.renesas.com/disclaimer 
*
* Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.    
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name    : resetprg.c
* Version      : 1.01
* Description  : Power on reset
***********************************************************************************************************************/
/**********************************************************************************************************************
* History : DD.MM.YYYY Version  Description
*         : 22.04.2011 1.00     First Release
*         : 21.08.2012 1.01     Change to supervisor mode
***********************************************************************************************************************/


/***********************************************************************************************************************
Includes   <System Includes> , "Project Includes"
***********************************************************************************************************************/
#include    <machine.h>
#include    <_h_c_lib.h>
#include    <stdint.h>
#include    "typedefine.h"
#include    "iodefine.h"
#include    "sci2.h"
//#include    "isr_vectors.h"

/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
#define PSW_init  0x00010000
#define FPSW_init 0x00000100
/***********************************************************************************************************************
Typedef definitions
***********************************************************************************************************************/

/***********************************************************************************************************************
Imported global variables and functions (from other files)
***********************************************************************************************************************/
//#ifdef __cplusplus                // Use SIM I/O
//extern "C" {
//#endif
//extern void _INIT_IOLIB(void);
//extern void _CLOSEALL(void);
//#ifdef __cplusplus
//}
//#endif

//extern void srand(_UINT);        // Remove the comment when you use rand()
//extern _SBYTE *_s1ptr;                // Remove the comment when you use strtok()
        
#ifdef __cplusplus                // Use Hardware Setup
extern "C" {
#endif
extern void main(void);
extern void HardwareSetup(void);
extern void tn_startup_hardware_init(void);
extern void tn_startup(void);
#ifdef __cplusplus
}
#endif
    
//#ifdef __cplusplus            // Remove the comment when you use global class object
//extern "C" {                    // Sections C$INIT and C$END will be generated
//#endif
//extern void _CALL_INIT(void);
//extern void _CALL_END(void);
//#ifdef __cplusplus
//}
//#endif
#define PSW_init  0x00000000    // PSW bit pattern
#define FPSW_init 0x00000100    // FPSW bit base pattern

/***********************************************************************************************************************
Exported global variables and functions (to be accessed by other files)
***********************************************************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
void PowerON_Reset_PC(void);
#ifdef __cplusplus
}
#endif

/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
#pragma section ResetPRG

#pragma entry PowerON_Reset_PC

/***********************************************************************************************************************
* Function Name: PowerON_Reset_PC
* Description  : Executes the CPU initialization processing to register 
*                the power-on reset vector to the exception vector table.
*                This function is executed first after power-on reset.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void PowerON_Reset_PC(void)
{ 

    set_psw(PSW_init);                // Set Ubit & Ibit for PSW

    set_fpsw(FPSW_init);
    
    set_intb(__sectop("C$VECT"));
    
    set_isp (0x400);
    
    tn_startup_hardware_init();

    _INITSCT();

    tn_startup();
    
    main();
    
    brk();
}

/* END of File */


5)intprg.c
省略
6 その他
http://japan.renesas.com/products/tools/middleware/c_communication/a_tcpip/tcpip_t4/index.jsp
にて公開されている無償版TCP/IP プロトコルスタックが便利です。

本家 http://www.tnkernel.com/ に Version 2.7があがっていた。

2013.07.22

2013年3月29日金曜日

HOSv4 RX63NをHEW で味見してみる

HOSV4をRX63N(GR-SAKURA)で試す。
以前 HOS V4 RX62Nを試したが
その時は http://sourceforge.jp/forum/message.php?msg_id=57491
のコード利用しました。
このコードは タスクスイッチのトリガーにRX62Nの SWINTR機能を使っています(Cortex-M3 PendSV命令相当)。
今回 http://sourceforge.jp/cvs/view/hos/hos/hos-v4/ の本家に RX600(RX621?)のコードが取り込まれたので、これを試します。 今回のコードでは RX621 の SWINTR機能は使われていません。
せっかくなので、 HEW環境で動作確認したい。

gcc版をのソースを修正しながら、組み込みます。
src/rx600/rxc/pacctx.src hew版
 ;/* ------------------------------------------------------------------------ */  
 ;/* Hyper Operating System V4 μITRON4.0仕様 Real-Time OS         */  
 ;/*  プロセッサ抽象化コンポーネント (Renesas RX用)              */  
 ;/*                                     */  
 ;/*                 Copyright (C) 1998-2012 by Project HOS */  
 ;/*                 http://sourceforge.jp/projects/hos/   */  
 ;/* ------------------------------------------------------------------------ */  
                     .glb     _hospac_ini_sys               ;/* 初期化 */  
                     .glb     _hospac_dis_int               ;/* 割り込み禁止 */  
                     .glb     _hospac_ena_int               ;/* 割り込み許可 */  
                     .glb     _hospac_cre_ctx_asm          ;/* 実行コンテキストの作成 */  
                     .glb     _hospac_swi_ctx               ;/* 実行コンテキストの切替 */  
                     .glb     _hospac_sh_imsk  
 ;/************************************************  
 ; プロセッサ抽象化コンポーネントの初期化  
 ; void hospac_ini_sys(void)  
 ;************************************************/  
                     .section P,CODE,ALIGN=4  
                     .align     4  
 _hospac_ini_sys:  
                     rts  
 ;/************************************************  
 ; 割り込み禁止  
 ; void hospac_dis_int(void)  
 ;************************************************/  
                     ;.text  
                     .align     4  
 _hospac_dis_int:  
                     ;mvfc     psw, r1  
                     ;bclr     #16, r1                    ;/* I bit clr 割り込みdisable */  
                     ;mvtc     r1, psw  
                     clrpsw i  
                     rts  
 ;/************************************************  
 ; 割り込み許可  
 ; void hospac_ena_int(void)  
 ;************************************************/  
                     ;.text  
                     .align     4  
 _hospac_ena_int:  
                     mov.l     #0f0ffffffh, r1          ;/* IPL[3:0]=0 */  
                     mvfc     psw, r2  
                     and          r1, r2                    ;/* 割り込みマスク値以外を取得 */  
                     mov.l     #_hospac_sh_imsk, r1  
                     mov.l     [r1], r1  
                     or          r1, r2                    ;/* 割り込みマスクの値を設定 */  
                     mvtc     r2, psw  
                     setpsw     i                         ;/* I bit set */  
                     rts  
 ;/************************************************  
 ; 実行コンテキストエントリーアドレス  
 ;************************************************/  
                     ;.text  
                     .align 4  
 ctx_entry:             
                     mov.l     r7, r1                    ;/* 実行時パラメータを第一引数に設定 !!!レジスタ確認*/  
                     jmp          r6                         ;/* 実行アドレスにジャンプ !!!レジスタ確認*/  
 ;/************************************************  
 ; 実行コンテキストの作成  
 ; void hospac_cre_ctx_asm(  
 ;           T_HOSPAC_CTXINF *pk_ctxinf,     作成するコンテキスト  
 ;           VP      sp,                          スタックポインタ  
 ;           void     (*task)(VP_INT),          実行アドレス  
 ;           VP_INT exinf)                         実行時パラメータ  
 ;************************************************/  
                     ;.text  
                     .align 4  
 _hospac_cre_ctx_asm:  
                     mov.l     #ctx_entry, r5          ;/* 実行エントリポイントをコンテキストの */  
                     mov.l     r5, [-r2]               ;/* スタックに保存 */  
                     add      #-28, r2               ;/* r8-14分コンテキストのstackを伸ばす */  
                     mov.l     r4, [-r2]               ;/* 実行パラメータの格納(r7) */  
                     mov.l     r3, [-r2]               ;/* 実行アドレスの格納(r6) */  
                     mov.l     r2, 0[r1]                ;/* コンテキストのスタックポインタ保存 */  
                     rts  
 ;/************************************************  
 ; 実行コンテキストの切替  
 ; void hospac_swi_ctx(  
 ;          T_HOSPAC_CTXINF *pk_pre_ctxinf,     現在のコンテキストの保存先  
 ;          T_HOSPAC_CTXINF *pk_nxt_ctxinf)     切り替えるコンテキスト  
 ;************************************************/  
                     ;.text  
                     .align 4  
 _hospac_swi_ctx:  
                     pushm     r6-r14          ;/* r6-r14を退避 !!!使用レジスタが合っているか確認*/  
                     mov.l      r0, 0[r1]     ;/* スタックポインタ保存 */  
                     mov.l      0[r2], r0     ;/* スタックポインタ復帰 */  
                     popm     r6-r14          ;/* r6-r14を復帰 !!!使用レジスタが合っているか確認*/  
                     rts  
                     .end  
 ;/* ------------------------------------------------------------------------ */  
 ;/* Copyright (C) 1998-2012 by Project HOS                 */  
 ;/* ------------------------------------------------------------------------ */  

src/rx600/rxc/pacint.src hew版
 ;/* ------------------------------------------------------------------------ */  
 ;/* Hyper Operating System V4 μITRON4.0仕様 Real-Time OS         */  
 ;/*  プロセッサ抽象化コンポーネント (Renesas RX用)              */  
 ;/*  割り込みハンドラ                           */  
 ;/*                                     */  
 ;/*                 Copyright (C) 1998-2012 by Project HOS */  
 ;/*                 http://sourceforge.jp/projects/hos/   */  
 ;/* ------------------------------------------------------------------------ */  
                     .glb     _hospac_sh_imsk  
                     .glb     _hospac_sh_imsk_base  
                     .glb     _kernel_int_cnt  
                     .glb     _kernel_exe_int  
                     .glb     _kernel_end_int  
                     .glb     _kernel_int_ssp  
                     .glb     _kernel_sta_int  
                     .glb     _hos_vecter000  
                     .glb     _hos_vecter001  
                     .glb     _hos_vecter002  
                     .glb     _hos_vecter003  
                     .glb     _hos_vecter004  
                     .glb     _hos_vecter005  
                     .glb     _hos_vecter006  
                     .glb     _hos_vecter007  
                     .glb     _hos_vecter008  
                     .glb     _hos_vecter009  
                     .glb     _hos_vecter010  
                     .glb     _hos_vecter011  
                     .glb     _hos_vecter012  
                     .glb     _hos_vecter013  
                     .glb     _hos_vecter014  
                     .glb     _hos_vecter015  
                     .glb     _hos_vecter016  
                     .glb     _hos_vecter017  
                     .glb     _hos_vecter018  
                     .glb     _hos_vecter019  
                     .glb     _hos_vecter020  
                     .glb     _hos_vecter021  
                     .glb     _hos_vecter022  
                     .glb     _hos_vecter023  
                     .glb     _hos_vecter024  
                     .glb     _hos_vecter025  
                     .glb     _hos_vecter026  
                     .glb     _hos_vecter027  
                     .glb     _hos_vecter028  
                     .glb     _hos_vecter029  
                     .glb     _hos_vecter030  
                     .glb     _hos_vecter031  
                     .glb     _hos_vecter032  
                     .glb     _hos_vecter033  
                     .glb     _hos_vecter034  
                     .glb     _hos_vecter035  
                     .glb     _hos_vecter036  
                     .glb     _hos_vecter037  
                     .glb     _hos_vecter038  
                     .glb     _hos_vecter039  
                     .glb     _hos_vecter040  
                     .glb     _hos_vecter041  
                     .glb     _hos_vecter042  
                     .glb     _hos_vecter043  
                     .glb     _hos_vecter044  
                     .glb     _hos_vecter045  
                     .glb     _hos_vecter046  
                     .glb     _hos_vecter047  
                     .glb     _hos_vecter048  
                     .glb     _hos_vecter049  
                     .glb     _hos_vecter050  
                     .glb     _hos_vecter051  
                     .glb     _hos_vecter052  
                     .glb     _hos_vecter053  
                     .glb     _hos_vecter054  
                     .glb     _hos_vecter055  
                     .glb     _hos_vecter056  
                     .glb     _hos_vecter057  
                     .glb     _hos_vecter058  
                     .glb     _hos_vecter059  
                     .glb     _hos_vecter060  
                     .glb     _hos_vecter061  
                     .glb     _hos_vecter062  
                     .glb     _hos_vecter063  
                     .glb     _hos_vecter064  
                     .glb     _hos_vecter065  
                     .glb     _hos_vecter066  
                     .glb     _hos_vecter067  
                     .glb     _hos_vecter068  
                     .glb     _hos_vecter069  
                     .glb     _hos_vecter070  
                     .glb     _hos_vecter071  
                     .glb     _hos_vecter072  
                     .glb     _hos_vecter073  
                     .glb     _hos_vecter074  
                     .glb     _hos_vecter075  
                     .glb     _hos_vecter076  
                     .glb     _hos_vecter077  
                     .glb     _hos_vecter078  
                     .glb     _hos_vecter079  
                     .glb     _hos_vecter080  
                     .glb     _hos_vecter081  
                     .glb     _hos_vecter082  
                     .glb     _hos_vecter083  
                     .glb     _hos_vecter084  
                     .glb     _hos_vecter085  
                     .glb     _hos_vecter086  
                     .glb     _hos_vecter087  
                     .glb     _hos_vecter088  
                     .glb     _hos_vecter089  
                     .glb     _hos_vecter090  
                     .glb     _hos_vecter091  
                     .glb     _hos_vecter092  
                     .glb     _hos_vecter093  
                     .glb     _hos_vecter094  
                     .glb     _hos_vecter095  
                     .glb     _hos_vecter096  
                     .glb     _hos_vecter097  
                     .glb     _hos_vecter098  
                     .glb     _hos_vecter099  
                     .glb     _hos_vecter100  
                     .glb     _hos_vecter101  
                     .glb     _hos_vecter102  
                     .glb     _hos_vecter103  
                     .glb     _hos_vecter104  
                     .glb     _hos_vecter105  
                     .glb     _hos_vecter106  
                     .glb     _hos_vecter107  
                     .glb     _hos_vecter108  
                     .glb     _hos_vecter109  
                     .glb     _hos_vecter110  
                     .glb     _hos_vecter111  
                     .glb     _hos_vecter112  
                     .glb     _hos_vecter113  
                     .glb     _hos_vecter114  
                     .glb     _hos_vecter115  
                     .glb     _hos_vecter116  
                     .glb     _hos_vecter117  
                     .glb     _hos_vecter118  
                     .glb     _hos_vecter119  
                     .glb     _hos_vecter120  
                     .glb     _hos_vecter121  
                     .glb     _hos_vecter122  
                     .glb     _hos_vecter123  
                     .glb     _hos_vecter124  
                     .glb     _hos_vecter125  
                     .glb     _hos_vecter126  
                     .glb     _hos_vecter127  
                     .glb     _hos_vecter128  
                     .glb     _hos_vecter129  
                     .glb     _hos_vecter130  
                     .glb     _hos_vecter131  
                     .glb     _hos_vecter132  
                     .glb     _hos_vecter133  
                     .glb     _hos_vecter134  
                     .glb     _hos_vecter135  
                     .glb     _hos_vecter136  
                     .glb     _hos_vecter137  
                     .glb     _hos_vecter138  
                     .glb     _hos_vecter139  
                     .glb     _hos_vecter140  
                     .glb     _hos_vecter141  
                     .glb     _hos_vecter142  
                     .glb     _hos_vecter143  
                     .glb     _hos_vecter144  
                     .glb     _hos_vecter145  
                     .glb     _hos_vecter146  
                     .glb     _hos_vecter147  
                     .glb     _hos_vecter148  
                     .glb     _hos_vecter149  
                     .glb     _hos_vecter150  
                     .glb     _hos_vecter151  
                     .glb     _hos_vecter152  
                     .glb     _hos_vecter153  
                     .glb     _hos_vecter154  
                     .glb     _hos_vecter155  
                     .glb     _hos_vecter156  
                     .glb     _hos_vecter157  
                     .glb     _hos_vecter158  
                     .glb     _hos_vecter159  
                     .glb     _hos_vecter160  
                     .glb     _hos_vecter161  
                     .glb     _hos_vecter162  
                     .glb     _hos_vecter163  
                     .glb     _hos_vecter164  
                     .glb     _hos_vecter165  
                     .glb     _hos_vecter166  
                     .glb     _hos_vecter167  
                     .glb     _hos_vecter168  
                     .glb     _hos_vecter169  
                     .glb     _hos_vecter170  
                     .glb     _hos_vecter171  
                     .glb     _hos_vecter172  
                     .glb     _hos_vecter173  
                     .glb     _hos_vecter174  
                     .glb     _hos_vecter175  
                     .glb     _hos_vecter176  
                     .glb     _hos_vecter177  
                     .glb     _hos_vecter178  
                     .glb     _hos_vecter179  
                     .glb     _hos_vecter180  
                     .glb     _hos_vecter181  
                     .glb     _hos_vecter182  
                     .glb     _hos_vecter183  
                     .glb     _hos_vecter184  
                     .glb     _hos_vecter185  
                     .glb     _hos_vecter186  
                     .glb     _hos_vecter187  
                     .glb     _hos_vecter188  
                     .glb     _hos_vecter189  
                     .glb     _hos_vecter190  
                     .glb     _hos_vecter191  
                     .glb     _hos_vecter192  
                     .glb     _hos_vecter193  
                     .glb     _hos_vecter194  
                     .glb     _hos_vecter195  
                     .glb     _hos_vecter196  
                     .glb     _hos_vecter197  
                     .glb     _hos_vecter198  
                     .glb     _hos_vecter199  
                     .glb     _hos_vecter200  
                     .glb     _hos_vecter201  
                     .glb     _hos_vecter202  
                     .glb     _hos_vecter203  
                     .glb     _hos_vecter204  
                     .glb     _hos_vecter205  
                     .glb     _hos_vecter206  
                     .glb     _hos_vecter207  
                     .glb     _hos_vecter208  
                     .glb     _hos_vecter209  
                     .glb     _hos_vecter210  
                     .glb     _hos_vecter211  
                     .glb     _hos_vecter212  
                     .glb     _hos_vecter213  
                     .glb     _hos_vecter214  
                     .glb     _hos_vecter215  
                     .glb     _hos_vecter216  
                     .glb     _hos_vecter217  
                     .glb     _hos_vecter218  
                     .glb     _hos_vecter219  
                     .glb     _hos_vecter220  
                     .glb     _hos_vecter221  
                     .glb     _hos_vecter222  
                     .glb     _hos_vecter223  
                     .glb     _hos_vecter224  
                     .glb     _hos_vecter225  
                     .glb     _hos_vecter226  
                     .glb     _hos_vecter227  
                     .glb     _hos_vecter228  
                     .glb     _hos_vecter229  
                     .glb     _hos_vecter230  
                     .glb     _hos_vecter231  
                     .glb     _hos_vecter232  
                     .glb     _hos_vecter233  
                     .glb     _hos_vecter234  
                     .glb     _hos_vecter235  
                     .glb     _hos_vecter236  
                     .glb     _hos_vecter237  
                     .glb     _hos_vecter238  
                     .glb     _hos_vecter239  
                     .glb     _hos_vecter240  
                     .glb     _hos_vecter241  
                     .glb     _hos_vecter242  
                     .glb     _hos_vecter243  
                     .glb     _hos_vecter244  
                     .glb     _hos_vecter245  
                     .glb     _hos_vecter246  
                     .glb     _hos_vecter247  
                     .glb     _hos_vecter248  
                     .glb     _hos_vecter249  
                     .glb     _hos_vecter250  
                     .glb     _hos_vecter251  
                     .glb     _hos_vecter252  
                     .glb     _hos_vecter253  
                     .glb     _hos_vecter254  
                     .glb     _hos_vecter255  
                     .section P,CODE,ALIGN=4  
 ;/************************************************  
 ; 割り込みハンドラ  
 ;************************************************/  
 _hos_vecter000:     push.l     r4  
                     mov.l          #0, R4  
                     bra          int_handler  
 _hos_vecter001:     push.l     r4  
                     mov.l          #1, R4  
                     bra          int_handler  
 _hos_vecter002:     push.l     r4  
                     mov.l          #2, R4  
                     bra          int_handler  
 _hos_vecter003:     push.l     r4  
                     mov.l          #3, R4  
                     bra          int_handler  
 _hos_vecter004:     push.l     r4  
                     mov.l          #4, R4  
                     bra          int_handler  
 _hos_vecter005:     push.l     r4  
                     mov.l          #5, r4  
                     bra          int_handler  
 _hos_vecter006:     push.l     r4  
                     mov.l          #6, r4  
                     bra          int_handler  
 _hos_vecter007:     push.l     r4  
                     mov.l          #7, r4  
                     bra          int_handler  
 _hos_vecter008:     push.l     r4  
                     mov.l          #8, r4  
                     bra          int_handler  
 _hos_vecter009:     push.l     r4  
                     mov.l          #9, r4  
                     bra          int_handler  
 _hos_vecter010:     push.l     r4  
                     mov.l          #10, r4  
                     bra          int_handler  
 _hos_vecter011:     push.l     r4  
                     mov.l          #11, r4  
                     bra          int_handler  
 _hos_vecter012:     push.l     r4  
                     mov.l          #12, r4  
                     bra          int_handler  
 _hos_vecter013:     push.l     r4  
                     mov.l          #13, r4  
                     bra          int_handler  
 _hos_vecter014:     push.l     r4  
                     mov.l          #14, r4  
                     bra          int_handler  
 _hos_vecter015:     push.l     r4  
                     mov.l          #15, r4  
                     bra          int_handler  
 _hos_vecter016:     push.l     r4  
                     mov.l          #16, r4  
                     bra          int_handler  
 _hos_vecter017:     push.l     r4  
                     mov.l          #17, r4  
                     bra          int_handler  
 _hos_vecter018:     push.l     r4  
                     mov.l          #18, r4  
                     bra          int_handler  
 _hos_vecter019:     push.l     r4  
                     mov.l          #19, r4  
                     bra          int_handler  
 _hos_vecter020:     push.l     r4  
                     mov.l          #20, r4  
                     bra          int_handler  
 _hos_vecter021:     push.l     r4  
                     mov.l          #21, r4  
                     bra          int_handler  
 _hos_vecter022:     push.l     r4  
                     mov.l          #22, r4  
                     bra          int_handler  
 _hos_vecter023:     push.l     r4  
                     mov.l          #23, r4  
                     bra          int_handler  
 _hos_vecter024:     push.l     r4  
                     mov.l          #24, r4  
                     bra          int_handler  
 _hos_vecter025:     push.l     r4  
                     mov.l          #25, r4  
                     bra          int_handler  
 _hos_vecter026:     push.l     r4  
                     mov.l          #26, r4  
                     bra          int_handler  
 _hos_vecter027:     push.l     r4  
                     mov.l          #27, r4  
                     bra          int_handler  
 _hos_vecter028:     push.l     r4  
                     mov.l          #28, r4  
                     bra          int_handler  
 _hos_vecter029:     push.l     r4  
                     mov.l          #29, r4  
                     bra          int_handler  
 _hos_vecter030:     push.l     r4  
                     mov.l          #30, r4  
                     bra          int_handler  
 _hos_vecter031:     push.l     r4  
                     mov.l          #31, r4  
                     bra          int_handler  
 _hos_vecter032:     push.l     r4  
                     mov.l          #32, r4  
                     bra          int_handler  
 _hos_vecter033:     push.l     r4  
                     mov.l          #33, r4  
                     bra          int_handler  
 _hos_vecter034:     push.l     r4  
                     mov.l          #34, r4  
                     bra          int_handler  
 _hos_vecter035:     push.l     r4  
                     mov.l          #35, r4  
                     bra          int_handler  
 _hos_vecter036:     push.l     r4  
                     mov.l          #36, r4  
                     bra          int_handler  
 _hos_vecter037:     push.l     r4  
                     mov.l          #37, r4  
                     bra          int_handler  
 _hos_vecter038:     push.l     r4  
                     mov.l          #38, r4  
                     bra          int_handler  
 _hos_vecter039:     push.l     r4  
                     mov.l          #39, r4  
                     bra          int_handler  
 _hos_vecter040:     push.l     r4  
                     mov.l          #40, r4  
                     bra          int_handler  
 _hos_vecter041:     push.l     r4  
                     mov.l          #41, r4  
                     bra          int_handler  
 _hos_vecter042:     push.l     r4  
                     mov.l          #42, r4  
                     bra          int_handler  
 _hos_vecter043:     push.l     r4  
                     mov.l          #43, r4  
                     bra          int_handler  
 _hos_vecter044:     push.l     r4  
                     mov.l          #44, r4  
                     bra          int_handler  
 _hos_vecter045:     push.l     r4  
                     mov.l          #45, r4  
                     bra          int_handler  
 _hos_vecter046:     push.l     r4  
                     mov.l          #46, r4  
                     bra          int_handler  
 _hos_vecter047:     push.l     r4  
                     mov.l          #47, r4  
                     bra          int_handler  
 _hos_vecter048:     push.l     r4  
                     mov.l          #48, r4  
                     bra          int_handler  
 _hos_vecter049:     push.l     r4  
                     mov.l          #49, r4  
                     bra          int_handler  
 _hos_vecter050:     push.l     r4  
                     mov.l          #50, r4  
                     bra          int_handler  
 _hos_vecter051:     push.l     r4  
                     mov.l          #51, r4  
                     bra          int_handler  
 _hos_vecter052:     push.l     r4  
                     mov.l          #52, r4  
                     bra          int_handler  
 _hos_vecter053:     push.l     r4  
                     mov.l          #53, r4  
                     bra          int_handler  
 _hos_vecter054:     push.l     r4  
                     mov.l          #54, r4  
                     bra          int_handler  
 _hos_vecter055:     push.l     r4  
                     mov.l          #55, r4  
                     bra          int_handler  
 _hos_vecter056:     push.l     r4  
                     mov.l          #56, r4  
                     bra          int_handler  
 _hos_vecter057:     push.l     r4  
                     mov.l          #57, r4  
                     bra          int_handler  
 _hos_vecter058:     push.l     r4  
                     mov.l          #58, r4  
                     bra          int_handler  
 _hos_vecter059:     push.l     r4  
                     mov.l          #59, r4  
                     bra          int_handler  
 _hos_vecter060:     push.l     r4  
                     mov.l          #60, r4  
                     bra          int_handler  
 _hos_vecter061:     push.l     r4  
                     mov.l          #61, r4  
                     bra          int_handler  
 _hos_vecter062:     push.l     r4  
                     mov.l          #62, r4  
                     bra          int_handler  
 _hos_vecter063:     push.l     r4  
                     mov.l          #63, r4  
                     bra          int_handler  
 _hos_vecter064:     push.l     r4  
                     mov.l          #64, r4  
                     bra          int_handler  
 _hos_vecter065:     push.l     r4  
                     mov.l          #65, r4  
                     bra          int_handler  
 _hos_vecter066:     push.l     r4  
                     mov.l          #66, r4  
                     bra          int_handler  
 _hos_vecter067:     push.l     r4  
                     mov.l          #67, r4  
                     bra          int_handler  
 _hos_vecter068:     push.l     r4  
                     mov.l          #68, r4  
                     bra          int_handler  
 _hos_vecter069:     push.l     r4  
                     mov.l          #69, r4  
                     bra          int_handler  
 _hos_vecter070:     push.l     r4  
                     mov.l          #70, r4  
                     bra          int_handler  
 _hos_vecter071:     push.l     r4  
                     mov.l          #71, r4  
                     bra          int_handler  
 _hos_vecter072:     push.l     r4  
                     mov.l          #72, r4  
                     bra          int_handler  
 _hos_vecter073:     push.l     r4  
                     mov.l          #73, r4  
                     bra          int_handler  
 _hos_vecter074:     push.l     r4  
                     mov.l          #74, r4  
                     bra          int_handler  
 _hos_vecter075:     push.l     r4  
                     mov.l          #75, r4  
                     bra          int_handler  
 _hos_vecter076:     push.l     r4  
                     mov.l          #76, r4  
                     bra          int_handler  
 _hos_vecter077:     push.l     r4  
                     mov.l          #77, r4  
                     bra          int_handler  
 _hos_vecter078:     push.l     r4  
                     mov.l          #78, r4  
                     bra          int_handler  
 _hos_vecter079:     push.l     r4  
                     mov.l          #79, r4  
                     bra          int_handler  
 _hos_vecter080:     push.l     r4  
                     mov.l          #80, r4  
                     bra          int_handler  
 _hos_vecter081:     push.l     r4  
                     mov.l          #81, r4  
                     bra          int_handler  
 _hos_vecter082:     push.l     r4  
                     mov.l          #82, r4  
                     bra          int_handler  
 _hos_vecter083:     push.l     r4  
                     mov.l          #83, r4  
                     bra          int_handler  
 _hos_vecter084:     push.l     r4  
                     mov.l          #84, r4  
                     bra          int_handler  
 _hos_vecter085:     push.l     r4  
                     mov.l          #85, r4  
                     bra          int_handler  
 _hos_vecter086:     push.l     r4  
                     mov.l          #86, r4  
                     bra          int_handler  
 _hos_vecter087:     push.l     r4  
                     mov.l          #87, r4  
                     bra          int_handler  
 _hos_vecter088:     push.l     r4  
                     mov.l          #88, r4  
                     bra          int_handler  
 _hos_vecter089:     push.l     r4  
                     mov.l          #89, r4  
                     bra          int_handler  
 _hos_vecter090:     push.l     r4  
                     mov.l          #90, r4  
                     bra          int_handler  
 _hos_vecter091:     push.l     r4  
                     mov.l          #91, r4  
                     bra          int_handler  
 _hos_vecter092:     push.l     r4  
                     mov.l          #92, r4  
                     bra          int_handler  
 _hos_vecter093:     push.l     r4  
                     mov.l          #93, r4  
                     bra          int_handler  
 _hos_vecter094:     push.l     r4  
                     mov.l          #94, r4  
                     bra          int_handler  
 _hos_vecter095:     push.l     r4  
                     mov.l          #95, r4  
                     bra          int_handler  
 _hos_vecter096:     push.l     r4  
                     mov.l          #96, r4  
                     bra          int_handler  
 _hos_vecter097:     push.l     r4  
                     mov.l          #97, r4  
                     bra          int_handler  
 _hos_vecter098:     push.l     r4  
                     mov.l          #98, r4  
                     bra          int_handler  
 _hos_vecter099:     push.l     r4  
                     mov.l          #99, r4  
                     bra          int_handler  
 _hos_vecter100:     push.l     r4  
                     mov.l          #100, r4  
                     bra          int_handler  
 _hos_vecter101:     push.l     r4  
                     mov.l          #101, r4  
                     bra          int_handler  
 _hos_vecter102:     push.l     r4  
                     mov.l          #102, r4  
                     bra          int_handler  
 _hos_vecter103:     push.l     r4  
                     mov.l          #103, r4  
                     bra          int_handler  
 _hos_vecter104:     push.l     r4  
                     mov.l          #104, r4  
                     bra          int_handler  
 _hos_vecter105:     push.l     r4  
                     mov.l          #105, r4  
                     bra          int_handler  
 _hos_vecter106:     push.l     r4  
                     mov.l          #106, r4  
                     bra          int_handler  
 _hos_vecter107:     push.l     r4  
                     mov.l          #107, r4  
                     bra          int_handler  
 _hos_vecter108:     push.l     r4  
                     mov.l          #108, r4  
                     bra          int_handler  
 _hos_vecter109:     push.l     r4  
                     mov.l          #109, r4  
                     bra          int_handler  
 _hos_vecter110:     push.l     r4  
                     mov.l          #110, r4  
                     bra          int_handler  
 _hos_vecter111:     push.l     r4  
                     mov.l          #111, r4  
                     bra          int_handler  
 _hos_vecter112:     push.l     r4  
                     mov.l          #112, r4  
                     bra          int_handler  
 _hos_vecter113:     push.l     r4  
                     mov.l          #113, r4  
                     bra          int_handler  
 _hos_vecter114:     push.l     r4  
                     mov.l          #114, r4  
                     bra          int_handler  
 _hos_vecter115:     push.l     r4  
                     mov.l          #115, r4  
                     bra          int_handler  
 _hos_vecter116:     push.l     r4  
                     mov.l          #116, r4  
                     bra          int_handler  
 _hos_vecter117:     push.l     r4  
                     mov.l          #117, r4  
                     bra          int_handler  
 _hos_vecter118:     push.l     r4  
                     mov.l          #118, r4  
                     bra          int_handler  
 _hos_vecter119:     push.l     r4  
                     mov.l          #119, r4  
                     bra          int_handler  
 _hos_vecter120:     push.l     r4  
                     mov.l          #120, r4  
                     bra          int_handler  
 _hos_vecter121:     push.l     r4  
                     mov.l          #121, r4  
                     bra          int_handler  
 _hos_vecter122:     push.l     r4  
                     mov.l          #122, r4  
                     bra          int_handler  
 _hos_vecter123:     push.l     r4  
                     mov.l          #123, r4  
                     bra          int_handler  
 _hos_vecter124:     push.l     r4  
                     mov.l          #124, r4  
                     bra          int_handler  
 _hos_vecter125:     push.l     r4  
                     mov.l          #125, r4  
                     bra          int_handler  
 _hos_vecter126:     push.l     r4  
                     mov.l          #126, r4  
                     bra          int_handler  
 _hos_vecter127:     push.l     r4  
                     mov.l          #127, r4  
                     bra          int_handler  
 _hos_vecter128:     push.l     r4  
                     mov.l          #128, r4  
                     bra          int_handler  
 _hos_vecter129:     push.l     r4  
                     mov.l          #129, r4  
                     bra          int_handler  
 _hos_vecter130:     push.l     r4  
                     mov.l          #130, r4  
                     bra          int_handler  
 _hos_vecter131:     push.l     r4  
                     mov.l          #131, r4  
                     bra          int_handler  
 _hos_vecter132:     push.l     r4  
                     mov.l          #132, r4  
                     bra          int_handler  
 _hos_vecter133:     push.l     r4  
                     mov.l          #133, r4  
                     bra          int_handler  
 _hos_vecter134:     push.l     r4  
                     mov.l          #134, r4  
                     bra          int_handler  
 _hos_vecter135:     push.l     r4  
                     mov.l          #135, r4  
                     bra          int_handler  
 _hos_vecter136:     push.l     r4  
                     mov.l          #136, r4  
                     bra          int_handler  
 _hos_vecter137:     push.l     r4  
                     mov.l          #137, r4  
                     bra          int_handler  
 _hos_vecter138:     push.l     r4  
                     mov.l          #138, r4  
                     bra          int_handler  
 _hos_vecter139:     push.l     r4  
                     mov.l          #139, r4  
                     bra          int_handler  
 _hos_vecter140:     push.l     r4  
                     mov.l          #140, r4  
                     bra          int_handler  
 _hos_vecter141:     push.l     r4  
                     mov.l          #141, r4  
                     bra          int_handler  
 _hos_vecter142:     push.l     r4  
                     mov.l          #142, r4  
                     bra          int_handler  
 _hos_vecter143:     push.l     r4  
                     mov.l          #143, r4  
                     bra          int_handler  
 _hos_vecter144:     push.l     r4  
                     mov.l          #144, r4  
                     bra          int_handler  
 _hos_vecter145:     push.l     r4  
                     mov.l          #145, r4  
                     bra          int_handler  
 _hos_vecter146:     push.l     r4  
                     mov.l          #146, r4  
                     bra          int_handler  
 _hos_vecter147:     push.l     r4  
                     mov.l          #147, r4  
                     bra          int_handler  
 _hos_vecter148:     push.l     r4  
                     mov.l          #148, r4  
                     bra          int_handler  
 _hos_vecter149:     push.l     r4  
                     mov.l          #149, r4  
                     bra          int_handler  
 _hos_vecter150:     push.l     r4  
                     mov.l          #150, r4  
                     bra          int_handler  
 _hos_vecter151:     push.l     r4  
                     mov.l          #151, r4  
                     bra          int_handler  
 _hos_vecter152:     push.l     r4  
                     mov.l          #152, r4  
                     bra          int_handler  
 _hos_vecter153:     push.l     r4  
                     mov.l          #153, r4  
                     bra          int_handler  
 _hos_vecter154:     push.l     r4  
                     mov.l          #154, r4  
                     bra          int_handler  
 _hos_vecter155:     push.l     r4  
                     mov.l          #155, r4  
                     bra          int_handler  
 _hos_vecter156:     push.l     r4  
                     mov.l          #156, r4  
                     bra          int_handler  
 _hos_vecter157:     push.l     r4  
                     mov.l          #157, r4  
                     bra          int_handler  
 _hos_vecter158:     push.l     r4  
                     mov.l          #158, r4  
                     bra          int_handler  
 _hos_vecter159:     push.l     r4  
                     mov.l          #159, r4  
                     bra          int_handler  
 _hos_vecter160:     push.l     r4  
                     mov.l          #160, r4  
                     bra          int_handler  
 _hos_vecter161:     push.l     r4  
                     mov.l          #161, r4  
                     bra          int_handler  
 _hos_vecter162:     push.l     r4  
                     mov.l          #162, r4  
                     bra          int_handler  
 _hos_vecter163:     push.l     r4  
                     mov.l          #163, r4  
                     bra          int_handler  
 _hos_vecter164:     push.l     r4  
                     mov.l          #164, r4  
                     bra          int_handler  
 _hos_vecter165:     push.l     r4  
                     mov.l          #165, r4  
                     bra          int_handler  
 _hos_vecter166:     push.l     r4  
                     mov.l          #166, r4  
                     bra          int_handler  
 _hos_vecter167:     push.l     r4  
                     mov.l          #167, r4  
                     bra          int_handler  
 _hos_vecter168:     push.l     r4  
                     mov.l          #168, r4  
                     bra          int_handler  
 _hos_vecter169:     push.l     r4  
                     mov.l          #169, r4  
                     bra          int_handler  
 _hos_vecter170:     push.l     r4  
                     mov.l          #170, r4  
                     bra          int_handler  
 _hos_vecter171:     push.l     r4  
                     mov.l          #171, r4  
                     bra          int_handler  
 _hos_vecter172:     push.l     r4  
                     mov.l          #172, r4  
                     bra          int_handler  
 _hos_vecter173:     push.l     r4  
                     mov.l          #173, r4  
                     bra          int_handler  
 _hos_vecter174:     push.l     r4  
                     mov.l          #174, r4  
                     bra          int_handler  
 _hos_vecter175:     push.l     r4  
                     mov.l          #175, r4  
                     bra          int_handler  
 _hos_vecter176:     push.l     r4  
                     mov.l          #176, r4  
                     bra          int_handler  
 _hos_vecter177:     push.l     r4  
                     mov.l          #177, r4  
                     bra          int_handler  
 _hos_vecter178:     push.l     r4  
                     mov.l          #178, r4  
                     bra          int_handler  
 _hos_vecter179:     push.l     r4  
                     mov.l          #179, r4  
                     bra          int_handler  
 _hos_vecter180:     push.l     r4  
                     mov.l          #180, r4  
                     bra          int_handler  
 _hos_vecter181:     push.l     r4  
                     mov.l          #181, r4  
                     bra          int_handler  
 _hos_vecter182:     push.l     r4  
                     mov.l          #182, r4  
                     bra          int_handler  
 _hos_vecter183:     push.l     r4  
                     mov.l          #183, r4  
                     bra          int_handler  
 _hos_vecter184:     push.l     r4  
                     mov.l          #184, r4  
                     bra          int_handler  
 _hos_vecter185:     push.l     r4  
                     mov.l          #185, r4  
                     bra          int_handler  
 _hos_vecter186:     push.l     r4  
                     mov.l          #186, r4  
                     bra          int_handler  
 _hos_vecter187:     push.l     r4  
                     mov.l          #187, r4  
                     bra          int_handler  
 _hos_vecter188:     push.l     r4  
                     mov.l          #188, r4  
                     bra          int_handler  
 _hos_vecter189:     push.l     r4  
                     mov.l          #189, r4  
                     bra          int_handler  
 _hos_vecter190:     push.l     r4  
                     mov.l          #190, r4  
                     bra          int_handler  
 _hos_vecter191:     push.l     r4  
                     mov.l          #191, r4  
                     bra          int_handler  
 _hos_vecter192:     push.l     r4  
                     mov.l          #192, r4  
                     bra          int_handler  
 _hos_vecter193:     push.l     r4  
                     mov.l          #193, r4  
                     bra          int_handler  
 _hos_vecter194:     push.l     r4  
                     mov.l          #194, r4  
                     bra          int_handler  
 _hos_vecter195:     push.l     r4  
                     mov.l          #195, r4  
                     bra          int_handler  
 _hos_vecter196:     push.l     r4  
                     mov.l          #196, r4  
                     bra          int_handler  
 _hos_vecter197:     push.l     r4  
                     mov.l          #197, r4  
                     bra          int_handler  
 _hos_vecter198:     push.l     r4  
                     mov.l          #198, r4  
                     bra          int_handler  
 _hos_vecter199:     push.l     r4  
                     mov.l          #199, r4  
                     bra          int_handler  
 _hos_vecter200:     push.l     r4  
                     mov.l          #200, r4  
                     bra          int_handler  
 _hos_vecter201:     push.l     r4  
                     mov.l          #201, r4  
                     bra          int_handler  
 _hos_vecter202:     push.l     r4  
                     mov.l          #202, r4  
                     bra          int_handler  
 _hos_vecter203:     push.l     r4  
                     mov.l          #203, r4  
                     bra          int_handler  
 _hos_vecter204:     push.l     r4  
                     mov.l          #204, r4  
                     bra          int_handler  
 _hos_vecter205:     push.l     r4  
                     mov.l          #205, r4  
                     bra          int_handler  
 _hos_vecter206:     push.l     r4  
                     mov.l          #206, r4  
                     bra          int_handler  
 _hos_vecter207:     push.l     r4  
                     mov.l          #207, r4  
                     bra          int_handler  
 _hos_vecter208:     push.l     r4  
                     mov.l          #208, r4  
                     bra          int_handler  
 _hos_vecter209:     push.l     r4  
                     mov.l          #209, r4  
                     bra          int_handler  
 _hos_vecter210:     push.l     r4  
                     mov.l          #210, r4  
                     bra          int_handler  
 _hos_vecter211:     push.l     r4  
                     mov.l          #211, r4  
                     bra          int_handler  
 _hos_vecter212:     push.l     r4  
                     mov.l          #212, r4  
                     bra          int_handler  
 _hos_vecter213:     push.l     r4  
                     mov.l          #213, r4  
                     bra          int_handler  
 _hos_vecter214:     push.l     r4  
                     mov.l          #214, r4  
                     bra          int_handler  
 _hos_vecter215:     push.l     r4  
                     mov.l          #215, r4  
                     bra          int_handler  
 _hos_vecter216:     push.l     r4  
                     mov.l          #216, r4  
                     bra          int_handler  
 _hos_vecter217:     push.l     r4  
                     mov.l          #217, r4  
                     bra          int_handler  
 _hos_vecter218:     push.l     r4  
                     mov.l          #218, r4  
                     bra          int_handler  
 _hos_vecter219:     push.l     r4  
                     mov.l          #219, r4  
                     bra          int_handler  
 _hos_vecter220:     push.l     r4  
                     mov.l          #220, r4  
                     bra          int_handler  
 _hos_vecter221:     push.l     r4  
                     mov.l          #221, r4  
                     bra          int_handler  
 _hos_vecter222:     push.l     r4  
                     mov.l          #222, r4  
                     bra          int_handler  
 _hos_vecter223:     push.l     r4  
                     mov.l          #223, r4  
                     bra          int_handler  
 _hos_vecter224:     push.l     r4  
                     mov.l          #224, r4  
                     bra          int_handler  
 _hos_vecter225:     push.l     r4  
                     mov.l          #225, r4  
                     bra          int_handler  
 _hos_vecter226:     push.l     r4  
                     mov.l          #226, r4  
                     bra          int_handler  
 _hos_vecter227:     push.l     r4  
                     mov.l          #227, r4  
                     bra          int_handler  
 _hos_vecter228:     push.l     r4  
                     mov.l          #228, r4  
                     bra          int_handler  
 _hos_vecter229:     push.l     r4  
                     mov.l          #229, r4  
                     bra          int_handler  
 _hos_vecter230:     push.l     r4  
                     mov.l          #230, r4  
                     bra          int_handler  
 _hos_vecter231:     push.l     r4  
                     mov.l          #231, r4  
                     bra          int_handler  
 _hos_vecter232:     push.l     r4  
                     mov.l          #232, r4  
                     bra          int_handler  
 _hos_vecter233:     push.l     r4  
                     mov.l          #233, r4  
                     bra          int_handler  
 _hos_vecter234:     push.l     r4  
                     mov.l          #234, r4  
                     bra          int_handler  
 _hos_vecter235:     push.l     r4  
                     mov.l          #235, r4  
                     bra          int_handler  
 _hos_vecter236:     push.l     r4  
                     mov.l          #236, r4  
                     bra          int_handler  
 _hos_vecter237:     push.l     r4  
                     mov.l          #237, r4  
                     bra          int_handler  
 _hos_vecter238:     push.l     r4  
                     mov.l          #238, r4  
                     bra          int_handler  
 _hos_vecter239:     push.l     r4  
                     mov.l          #239, r4  
                     bra          int_handler  
 _hos_vecter240:     push.l     r4  
                     mov.l          #240, r4  
                     bra          int_handler  
 _hos_vecter241:     push.l     r4  
                     mov.l          #241, r4  
                     bra          int_handler  
 _hos_vecter242:     push.l     r4  
                     mov.l          #242, r4  
                     bra          int_handler  
 _hos_vecter243:     push.l     r4  
                     mov.l          #243, r4  
                     bra          int_handler  
 _hos_vecter244:     push.l     r4  
                     mov.l          #244, r4  
                     bra          int_handler  
 _hos_vecter245:     push.l     r4  
                     mov.l          #245, r4  
                     bra          int_handler  
 _hos_vecter246:     push.l     r4  
                     mov.l          #246, r4  
                     bra          int_handler  
 _hos_vecter247:     push.l     r4  
                     mov.l          #247, r4  
                     bra          int_handler  
 _hos_vecter248:     push.l     r4  
                     mov.l          #248, r4  
                     bra          int_handler  
 _hos_vecter249:     push.l     r4  
                     mov.l          #249, r4  
                     bra          int_handler  
 _hos_vecter250:     push.l     r4  
                     mov.l          #250, r4  
                     bra          int_handler  
 _hos_vecter251:     push.l     r4  
                     mov.l          #251, r4  
                     bra          int_handler  
 _hos_vecter252:     push.l     r4  
                     mov.l          #252, r4  
                     bra          int_handler  
 _hos_vecter253:     push.l     r4  
                     mov.l          #253, r4  
                     bra          int_handler  
 _hos_vecter254:     push.l     r4  
                     mov.l          #254, r4  
                     bra          int_handler  
 _hos_vecter255:     push.l     r4  
                     mov.l          #255, r4  
                     bra          int_handler  
 ;/************************************************  
 ; 割り込みハンドラ  
 ;  
 ; r4をスタックに積んだ後、r4に割り込み番号を  
 ; 格納してここに分岐するものとする  
 ;************************************************/  
                     .align     4  
 int_handler:       
                     ;/* レジスタ退避(r0-r2) */  
                     pushm     r1-r6  
                     pushm     r14-r15  
                     ;/* 割り込みマスク設定 */  
                     mvfc     psw, r1  
                     ;/* mov          r1, r2 */  
                     ;/* or          #0x0f000000, r1     */ /* 割り込み全マスク設定 */  
                     ;/* mvtc          r1, psw */  
                     ;/* 割り込みマスクの保存 */  
                     ;/* mov          r2, r1 */  
                     and          #0f000000h, r1  
                     mov.l     #_hospac_sh_imsk, r2  
                     mov.l     [r2], r6  
                     mov.l     r1, [r2]  
                     ;/* 割り込み番号の符号拡張をクリア */  
                     ;extu.b     r4, r4  
                     ;/* レジスタ保存(r3-r7,mach,macl,pr) */  
                     ;pushm r4-r15  
                     ;/* 多重割り込み判定 */  
                     mov.l     #_kernel_int_cnt, r2  
                     mov.l     [r2], r1  
                     add          #1, r1  
                     cmp     #1, r1  
                     bne     int_multi  
                     ;/* 単独割り込み時 */  
                     mov.l     r1, [r2]                    ;/* 割り込みネスト値を設定 */  
                     ;/* スタック入れ替え */ /* U bit でできないか検討 */  
                ;/* usp を利用しない場合1 begin */  
                     ; mov.l     #_kernel_int_ssp, r1  
                     ; mov.l     r0, [r1]               ;/* 現在のスタックを退避 */  
                     ; mov.l     #_kernel_int_sp, r1  
                     ; mov.l     [r1], r0               ;/* 割り込み用スタックを設定 */  
                ;/* usp利用しない場合1 end */   
                     push.l     r4               ;/* 割り込み番号を退避 */  
                     ;/* 割り込み開始処理呼び出し */  
                     mov.l     #_kernel_sta_int, r2 ;/* 状態変数を書き換え */  
                     jsr          r2  
                     ;/* 割り込み有効にする */  
                     setpsw     i  
                     ;/* 割り込み実行処理呼び出し */  
                     mov.l     #_kernel_exe_int, r2  
                     mov.l     [r0+], r4;/* pop.l */               /* 割り込み番号を引数とする */  
                     mov.l     r4, r1               ;r1がshでのr4かな  
                     jsr          r2  
                ;/* uspを利用しない場合2 begin*/  
                     ;/* スタックの復帰 */  
                     ; mov.l     #_kernel_int_ssp, r1  
                     ; mov.l     [r1], r0  
                ;/* uspを利用しない場合2 end */  
                ;/* uspに変更 uspを利用する場合 */  
                     ;/* 割り込み無効にする */  
                     clrpsw     i  
                     ;/* レジスタ一旦復帰 */  
                     popm     r14-r15  
                     popm     r1-r6  
                     ;/* uspへデータ写し */  
                     pushm     r5-r6;r6 r5  
                     mvfc     usp, r6  
                     mov.l     16[r0], r5;psw  
                     mov.l     r5, [-r6];psw  
                     mov.l     12[r0], r5;pc  
                     mov.l     r5, [-r6];pc  
                     mov.l     8[r0], r5;r4  
                     mov.l     r5, [-r6];r4  
                     mov.l     4[r0], r5;r6  
                     mov.l     r5, [-r6];r6  
                     mov.l     0[r0], r5;r5  
                     mov.l     r5, [-r6];r5  
                     mvtc     r6, usp  
                     add     #20, r0  
                     setpsw u  
                     ;/* uspにレジスタ改めて退避 */  
                     pushm     r1-r4  
                     pushm     r14-r15  
                ;/* uspに変更終わり */       
                     ;/* 割り込みカウンタのクリア */  
                     mov.l     #_kernel_int_cnt, r2  
                     xor          r1, r1  
                     mov.l     r1, [r2]  
                     ;/* ベースマスク値に戻す */  
                     mov.l     #_hospac_sh_imsk_base, r1  
                     mov.l     [r1], r2  
                     mov.l     #_hospac_sh_imsk, r1  
                     mov.l     r2, [r1]  
                     ;/* 割り込み終了処理呼び出し */  
                     mov.l     #_kernel_end_int, r2  
                     jsr          r2  
                     ;/* レジスタ復帰 */  
                     popm     r14-r15  
                     popm     r1-r6  
                     push.l     r1  
                     ;/* 復帰時割り込みマスクの設定 */ /* 復帰時マスク設定の必要性要確認 */  
                     mov.l     #_hospac_sh_imsk, r4  
                     mov.l     [r4], r4                         ;/* マスク値取得 */  
                     mov.l     12[r0], r1  
                     or          r4, r1  
                     mov.l     r1, 12[r0]               ;/* 復帰時SRのマスク設定 */  
                     mov.l     [r0+], r1  
                     mov.l     [r0+], r4  
                     rte  
                     ;/* 多重割り込み処理 */  
 int_multi:            
                     mov.l     r1, [r2]                    ;/* 割り込みネスト値を設定 */  
                     ;/* 割り込み有効にする */  
                     setpsw     i  
                     ;/* 割り込み実行処理呼び出し */  
                     mov.l     r4, r1  
                     mov.l     #_kernel_exe_int, r2  
                     jsr          r2               ;/* 割り込み番号を引数とする */  
                     ;/* 割り込みカウンタの減算 */  
                     mov.l     #_kernel_int_cnt, r2  
                     mov.l     [r2], r1  
                     add          #-1, r1  
                     mov.l     r1, [r2]  
                     ;/* 割り込み無効にする */  
                     clrpsw      i  
                     ;/* imask 復帰*/  
                     mov.l     #_hospac_sh_imsk, r2  
                     mov.l     r6, [r2]  
                     ;/* レジスタ復帰 */  
                     popm     r14-r15  
                     popm     r1-r6  
                     mov.l     [r0+], r4 ;/* pop.l */  
                     rte  
                     .end  
 ;/* ------------------------------------------------------------------------ */  
 ;/* Copyright (C) 1998-2012 by Project HOS                 */  
 ;/* ------------------------------------------------------------------------ */  

sample/rx600/system.cfg を修正します。
 /* ------------------------------------------------------------------------ */  
 /* Hyper Operating System V4 μITRON4.0仕様 Real-Time OS         */  
 /*  コンフィギュレーションファイル                    */  
 /*                                     */  
 /*                 Copyright (C) 1998-2002 by Project HOS */  
 /*                 http://sourceforge.jp/projects/hos/   */  
 /* ------------------------------------------------------------------------ */  
 /* RX63N */  
 #include "user_id.h"  
 /* HOS 独ゥの設定 */  
 HOS_KERNEL_HEAP(4096);          /* カーネルヒープの設定(省略時 0) */  
 HOS_TIM_TIC(1, 1);               /* タイムティックの設定(省略時 1/1 ) */  
 HOS_MAX_TPRI(8);               /* 最大優先度(省略時 16) */  
 HOS_MIN_INTNO(0);               /* 割り込み番号の最小値(省略時 0) */  
 HOS_MAX_INTNO(256);               /* 割り込み番号の最大値(省略時 0) */  
 HOS_MAX_TSKID(16);               /* 最大タスクID番号(省略時静的生成に必要なだけ) */  
 /* インクルードファイルの指定 */  
 INCLUDE("\"user_id.h\"");  
 INCLUDE("\"sample.h\"");  
 INCLUDE("\"iodefine.h\"");  
 INCLUDE("\"ostimer.h\"");  
 INCLUDE("\"sci.h\"");  
 /* OSタイマ用 */  
 ATT_ISR({TA_HLNG, 0, IR_CMT0_CMI0, ostim_hdr});  
 ATT_INI({TA_HLNG, 6000 - 1, ostim_init});  
 /* 哲学メ5人分のタスク */  
 CRE_TSK(TSKID_PHILOSOPHER1, {TA_HLNG, 1, PhilosopherTask, 1, 1024, NULL});  
 CRE_TSK(TSKID_PHILOSOPHER2, {TA_HLNG, 2, PhilosopherTask, 1, 512, NULL});  
 CRE_TSK(TSKID_PHILOSOPHER3, {TA_HLNG, 3, PhilosopherTask, 1, 512, NULL});  
 CRE_TSK(TSKID_PHILOSOPHER4, {TA_HLNG, 4, PhilosopherTask, 1, 512, NULL});  
 CRE_TSK(TSKID_PHILOSOPHER5, {TA_HLNG, 5, PhilosopherTask, 1, 512, NULL});  
 /* フォーク5本分のセマフォ */  
 CRE_SEM(SEMID_FORK1, {TA_TFIFO, 1, 1});  
 CRE_SEM(SEMID_FORK2, {TA_TFIFO, 1, 1});  
 CRE_SEM(SEMID_FORK3, {TA_TFIFO, 1, 1});  
 CRE_SEM(SEMID_FORK4, {TA_TFIFO, 1, 1});  
 CRE_SEM(SEMID_FORK5, {TA_TFIFO, 1, 1});  
 /* 初期化ルーチンの追加 */  
 ATT_INI({TA_HLNG, 0, SampleInitialize});  
 /* システム排他用 */  
 CRE_SEM(SEMID_SYSCS, {TA_TFIFO, 1, 1});  
 /* SCI用 */  
 CRE_FLG(FLGID_SCI1_SND, {TA_TFIFO | TA_WSGL | TA_CLR, 0});  
 CRE_SEM(SEMID_SCI1_RCV, {TA_TFIFO, 0, SCI_RCV_BUFSZ});  
 CRE_SEM(SEMID_SCI1_SND, {TA_TFIFO, 1, 1});  
 ATT_ISR({TA_HLNG, 1, IR_SCI2_TXI2, sci_snd_hdr});  
 ATT_ISR({TA_HLNG, 1, IR_SCI2_RXI2, sci_rcv_hdr});  
 /*ATT_INI({TA_HLNG, 0,     sci_init}); */  
 /* cyc */  
 CRE_CYC(CYC_ID, {TA_HLNG | TA_STA, 0, cyc_test, 500, 0});  
 /* ------------------------------------------------------------------------ */  
 /* Copyright (C) 1998-2002 by Project HOS                 */  
 /* ------------------------------------------------------------------------ */  

Borland C++のプリプロセッサを利用して
cpp32.exe -P- -osystem.i system.cfg
hos4cfg.exe system.i

kernel_cfg.c と kernel_id.h が得られます。

あとは
sample/rx600/vector.src hew版
 ;/* ------------------------------------------------------------------------ */  
 ;/* Hyper Operating System V4 サンプルプログラム              */  
 ;/*  割り込みベクタテーブル (日立 SH2 gcc 用)               */  
 ;/*                                     */  
 ;/*                 Copyright (C) 1998-2002 by Project HOS */  
 ;/*                 http://sourceforge.jp/projects/hos/   */  
 ;/* ------------------------------------------------------------------------ */  
                     .glb     _hos_vecter000  
                     .glb     _hos_vecter001  
                     .glb     _hos_vecter002  
                     .glb     _hos_vecter003  
                     .glb     _hos_vecter004  
                     .glb     _hos_vecter005  
                     .glb     _hos_vecter006  
                     .glb     _hos_vecter007  
                     .glb     _hos_vecter008  
                     .glb     _hos_vecter009  
                     .glb     _hos_vecter010  
                     .glb     _hos_vecter011  
                     .glb     _hos_vecter012  
                     .glb     _hos_vecter013  
                     .glb     _hos_vecter014  
                     .glb     _hos_vecter015  
                     .glb     _hos_vecter016  
                     .glb     _hos_vecter017  
                     .glb     _hos_vecter018  
                     .glb     _hos_vecter019  
                     .glb     _hos_vecter020  
                     .glb     _hos_vecter021  
                     .glb     _hos_vecter022  
                     .glb     _hos_vecter023  
                     .glb     _hos_vecter024  
                     .glb     _hos_vecter025  
                     .glb     _hos_vecter026  
                     .glb     _hos_vecter027  
                     .glb     _hos_vecter028  
                     .glb     _hos_vecter029  
                     .glb     _hos_vecter030  
                     .glb     _hos_vecter031  
                     .glb     _hos_vecter032  
                     .glb     _hos_vecter033  
                     .glb     _hos_vecter034  
                     .glb     _hos_vecter035  
                     .glb     _hos_vecter036  
                     .glb     _hos_vecter037  
                     .glb     _hos_vecter038  
                     .glb     _hos_vecter039  
                     .glb     _hos_vecter040  
                     .glb     _hos_vecter041  
                     .glb     _hos_vecter042  
                     .glb     _hos_vecter043  
                     .glb     _hos_vecter044  
                     .glb     _hos_vecter045  
                     .glb     _hos_vecter046  
                     .glb     _hos_vecter047  
                     .glb     _hos_vecter048  
                     .glb     _hos_vecter049  
                     .glb     _hos_vecter050  
                     .glb     _hos_vecter051  
                     .glb     _hos_vecter052  
                     .glb     _hos_vecter053  
                     .glb     _hos_vecter054  
                     .glb     _hos_vecter055  
                     .glb     _hos_vecter056  
                     .glb     _hos_vecter057  
                     .glb     _hos_vecter058  
                     .glb     _hos_vecter059  
                     .glb     _hos_vecter060  
                     .glb     _hos_vecter061  
                     .glb     _hos_vecter062  
                     .glb     _hos_vecter063  
                     .glb     _hos_vecter064  
                     .glb     _hos_vecter065  
                     .glb     _hos_vecter066  
                     .glb     _hos_vecter067  
                     .glb     _hos_vecter068  
                     .glb     _hos_vecter069  
                     .glb     _hos_vecter070  
                     .glb     _hos_vecter071  
                     .glb     _hos_vecter072  
                     .glb     _hos_vecter073  
                     .glb     _hos_vecter074  
                     .glb     _hos_vecter075  
                     .glb     _hos_vecter076  
                     .glb     _hos_vecter077  
                     .glb     _hos_vecter078  
                     .glb     _hos_vecter079  
                     .glb     _hos_vecter080  
                     .glb     _hos_vecter081  
                     .glb     _hos_vecter082  
                     .glb     _hos_vecter083  
                     .glb     _hos_vecter084  
                     .glb     _hos_vecter085  
                     .glb     _hos_vecter086  
                     .glb     _hos_vecter087  
                     .glb     _hos_vecter088  
                     .glb     _hos_vecter089  
                     .glb     _hos_vecter090  
                     .glb     _hos_vecter091  
                     .glb     _hos_vecter092  
                     .glb     _hos_vecter093  
                     .glb     _hos_vecter094  
                     .glb     _hos_vecter095  
                     .glb     _hos_vecter096  
                     .glb     _hos_vecter097  
                     .glb     _hos_vecter098  
                     .glb     _hos_vecter099  
                     .glb     _hos_vecter100  
                     .glb     _hos_vecter101  
                     .glb     _hos_vecter102  
                     .glb     _hos_vecter103  
                     .glb     _hos_vecter104  
                     .glb     _hos_vecter105  
                     .glb     _hos_vecter106  
                     .glb     _hos_vecter107  
                     .glb     _hos_vecter108  
                     .glb     _hos_vecter109  
                     .glb     _hos_vecter110  
                     .glb     _hos_vecter111  
                     .glb     _hos_vecter112  
                     .glb     _hos_vecter113  
                     .glb     _hos_vecter114  
                     .glb     _hos_vecter115  
                     .glb     _hos_vecter116  
                     .glb     _hos_vecter117  
                     .glb     _hos_vecter118  
                     .glb     _hos_vecter119  
                     .glb     _hos_vecter120  
                     .glb     _hos_vecter121  
                     .glb     _hos_vecter122  
                     .glb     _hos_vecter123  
                     .glb     _hos_vecter124  
                     .glb     _hos_vecter125  
                     .glb     _hos_vecter126  
                     .glb     _hos_vecter127  
                     .glb     _hos_vecter128  
                     .glb     _hos_vecter129  
                     .glb     _hos_vecter130  
                     .glb     _hos_vecter131  
                     .glb     _hos_vecter132  
                     .glb     _hos_vecter133  
                     .glb     _hos_vecter134  
                     .glb     _hos_vecter135  
                     .glb     _hos_vecter136  
                     .glb     _hos_vecter137  
                     .glb     _hos_vecter138  
                     .glb     _hos_vecter139  
                     .glb     _hos_vecter140  
                     .glb     _hos_vecter141  
                     .glb     _hos_vecter142  
                     .glb     _hos_vecter143  
                     .glb     _hos_vecter144  
                     .glb     _hos_vecter145  
                     .glb     _hos_vecter146  
                     .glb     _hos_vecter147  
                     .glb     _hos_vecter148  
                     .glb     _hos_vecter149  
                     .glb     _hos_vecter150  
                     .glb     _hos_vecter151  
                     .glb     _hos_vecter152  
                     .glb     _hos_vecter153  
                     .glb     _hos_vecter154  
                     .glb     _hos_vecter155  
                     .glb     _hos_vecter156  
                     .glb     _hos_vecter157  
                     .glb     _hos_vecter158  
                     .glb     _hos_vecter159  
                     .glb     _hos_vecter160  
                     .glb     _hos_vecter161  
                     .glb     _hos_vecter162  
                     .glb     _hos_vecter163  
                     .glb     _hos_vecter164  
                     .glb     _hos_vecter165  
                     .glb     _hos_vecter166  
                     .glb     _hos_vecter167  
                     .glb     _hos_vecter168  
                     .glb     _hos_vecter169  
                     .glb     _hos_vecter170  
                     .glb     _hos_vecter171  
                     .glb     _hos_vecter172  
                     .glb     _hos_vecter173  
                     .glb     _hos_vecter174  
                     .glb     _hos_vecter175  
                     .glb     _hos_vecter176  
                     .glb     _hos_vecter177  
                     .glb     _hos_vecter178  
                     .glb     _hos_vecter179  
                     .glb     _hos_vecter180  
                     .glb     _hos_vecter181  
                     .glb     _hos_vecter182  
                     .glb     _hos_vecter183  
                     .glb     _hos_vecter184  
                     .glb     _hos_vecter185  
                     .glb     _hos_vecter186  
                     .glb     _hos_vecter187  
                     .glb     _hos_vecter188  
                     .glb     _hos_vecter189  
                     .glb     _hos_vecter190  
                     .glb     _hos_vecter191  
                     .glb     _hos_vecter192  
                     .glb     _hos_vecter193  
                     .glb     _hos_vecter194  
                     .glb     _hos_vecter195  
                     .glb     _hos_vecter196  
                     .glb     _hos_vecter197  
                     .glb     _hos_vecter198  
                     .glb     _hos_vecter199  
                     .glb     _hos_vecter200  
                     .glb     _hos_vecter201  
                     .glb     _hos_vecter202  
                     .glb     _hos_vecter203  
                     .glb     _hos_vecter204  
                     .glb     _hos_vecter205  
                     .glb     _hos_vecter206  
                     .glb     _hos_vecter207  
                     .glb     _hos_vecter208  
                     .glb     _hos_vecter209  
                     .glb     _hos_vecter210  
                     .glb     _hos_vecter211  
                     .glb     _hos_vecter212  
                     .glb     _hos_vecter213  
                     .glb     _hos_vecter214  
                     .glb     _hos_vecter215  
                     .glb     _hos_vecter216  
                     .glb     _hos_vecter217  
                     .glb     _hos_vecter218  
                     .glb     _hos_vecter219  
                     .glb     _hos_vecter220  
                     .glb     _hos_vecter221  
                     .glb     _hos_vecter222  
                     .glb     _hos_vecter223  
                     .glb     _hos_vecter224  
                     .glb     _hos_vecter225  
                     .glb     _hos_vecter226  
                     .glb     _hos_vecter227  
                     .glb     _hos_vecter228  
                     .glb     _hos_vecter229  
                     .glb     _hos_vecter230  
                     .glb     _hos_vecter231  
                     .glb     _hos_vecter232  
                     .glb     _hos_vecter233  
                     .glb     _hos_vecter234  
                     .glb     _hos_vecter235  
                     .glb     _hos_vecter236  
                     .glb     _hos_vecter237  
                     .glb     _hos_vecter238  
                     .glb     _hos_vecter239  
                     .glb     _hos_vecter240  
                     .glb     _hos_vecter241  
                     .glb     _hos_vecter242  
                     .glb     _hos_vecter243  
                     .glb     _hos_vecter244  
                     .glb     _hos_vecter245  
                     .glb     _hos_vecter246  
                     .glb     _hos_vecter247  
                     .glb     _hos_vecter248  
                     .glb     _hos_vecter249  
                     .glb     _hos_vecter250  
                     .glb     _hos_vecter251  
                     .glb     _hos_vecter252  
                     .glb     _hos_vecter253  
                     .glb     _hos_vecter254  
                     .glb     _hos_vecter255  
                     .section C$VECT,CODE,ALIGN=4  
                     .lword     _hos_vecter000  
                     .lword     _hos_vecter001  
                     .lword     _hos_vecter002  
                     .lword     _hos_vecter003  
                     .lword     _hos_vecter004  
                     .lword     _hos_vecter005  
                     .lword     _hos_vecter006  
                     .lword     _hos_vecter007  
                     .lword     _hos_vecter008  
                     .lword     _hos_vecter009  
                     .lword     _hos_vecter010  
                     .lword     _hos_vecter011  
                     .lword     _hos_vecter012  
                     .lword     _hos_vecter013  
                     .lword     _hos_vecter014  
                     .lword     _hos_vecter015  
                     .lword     _hos_vecter016  
                     .lword     _hos_vecter017  
                     .lword     _hos_vecter018  
                     .lword     _hos_vecter019  
                     .lword     _hos_vecter020  
                     .lword     _hos_vecter021  
                     .lword     _hos_vecter022  
                     .lword     _hos_vecter023  
                     .lword     _hos_vecter024  
                     .lword     _hos_vecter025  
                     .lword     _hos_vecter026  
                     .lword     _hos_vecter027  
                     .lword     _hos_vecter028  
                     .lword     _hos_vecter029  
                     .lword     _hos_vecter030  
                     .lword     _hos_vecter031  
                     .lword     _hos_vecter032  
                     .lword     _hos_vecter033  
                     .lword     _hos_vecter034  
                     .lword     _hos_vecter035  
                     .lword     _hos_vecter036  
                     .lword     _hos_vecter037  
                     .lword     _hos_vecter038  
                     .lword     _hos_vecter039  
                     .lword     _hos_vecter040  
                     .lword     _hos_vecter041  
                     .lword     _hos_vecter042  
                     .lword     _hos_vecter043  
                     .lword     _hos_vecter044  
                     .lword     _hos_vecter045  
                     .lword     _hos_vecter046  
                     .lword     _hos_vecter047  
                     .lword     _hos_vecter048  
                     .lword     _hos_vecter049  
                     .lword     _hos_vecter050  
                     .lword     _hos_vecter051  
                     .lword     _hos_vecter052  
                     .lword     _hos_vecter053  
                     .lword     _hos_vecter054  
                     .lword     _hos_vecter055  
                     .lword     _hos_vecter056  
                     .lword     _hos_vecter057  
                     .lword     _hos_vecter058  
                     .lword     _hos_vecter059  
                     .lword     _hos_vecter060  
                     .lword     _hos_vecter061  
                     .lword     _hos_vecter062  
                     .lword     _hos_vecter063  
                     .lword     _hos_vecter064  
                     .lword     _hos_vecter065  
                     .lword     _hos_vecter066  
                     .lword     _hos_vecter067  
                     .lword     _hos_vecter068  
                     .lword     _hos_vecter069  
                     .lword     _hos_vecter070  
                     .lword     _hos_vecter071  
                     .lword     _hos_vecter072  
                     .lword     _hos_vecter073  
                     .lword     _hos_vecter074  
                     .lword     _hos_vecter075  
                     .lword     _hos_vecter076  
                     .lword     _hos_vecter077  
                     .lword     _hos_vecter078  
                     .lword     _hos_vecter079  
                     .lword     _hos_vecter080  
                     .lword     _hos_vecter081  
                     .lword     _hos_vecter082  
                     .lword     _hos_vecter083  
                     .lword     _hos_vecter084  
                     .lword     _hos_vecter085  
                     .lword     _hos_vecter086  
                     .lword     _hos_vecter087  
                     .lword     _hos_vecter088  
                     .lword     _hos_vecter089  
                     .lword     _hos_vecter090  
                     .lword     _hos_vecter091  
                     .lword     _hos_vecter092  
                     .lword     _hos_vecter093  
                     .lword     _hos_vecter094  
                     .lword     _hos_vecter095  
                     .lword     _hos_vecter096  
                     .lword     _hos_vecter097  
                     .lword     _hos_vecter098  
                     .lword     _hos_vecter099  
                     .lword     _hos_vecter100  
                     .lword     _hos_vecter101  
                     .lword     _hos_vecter102  
                     .lword     _hos_vecter103  
                     .lword     _hos_vecter104  
                     .lword     _hos_vecter105  
                     .lword     _hos_vecter106  
                     .lword     _hos_vecter107  
                     .lword     _hos_vecter108  
                     .lword     _hos_vecter109  
                     .lword     _hos_vecter110  
                     .lword     _hos_vecter111  
                     .lword     _hos_vecter112  
                     .lword     _hos_vecter113  
                     .lword     _hos_vecter114  
                     .lword     _hos_vecter115  
                     .lword     _hos_vecter116  
                     .lword     _hos_vecter117  
                     .lword     _hos_vecter118  
                     .lword     _hos_vecter119  
                     .lword     _hos_vecter120  
                     .lword     _hos_vecter121  
                     .lword     _hos_vecter122  
                     .lword     _hos_vecter123  
                     .lword     _hos_vecter124  
                     .lword     _hos_vecter125  
                     .lword     _hos_vecter126  
                     .lword     _hos_vecter127  
                     .lword     _hos_vecter128  
                     .lword     _hos_vecter129  
                     .lword     _hos_vecter130  
                     .lword     _hos_vecter131  
                     .lword     _hos_vecter132  
                     .lword     _hos_vecter133  
                     .lword     _hos_vecter134  
                     .lword     _hos_vecter135  
                     .lword     _hos_vecter136  
                     .lword     _hos_vecter137  
                     .lword     _hos_vecter138  
                     .lword     _hos_vecter139  
                     .lword     _hos_vecter140  
                     .lword     _hos_vecter141  
                     .lword     _hos_vecter142  
                     .lword     _hos_vecter143  
                     .lword     _hos_vecter144  
                     .lword     _hos_vecter145  
                     .lword     _hos_vecter146  
                     .lword     _hos_vecter147  
                     .lword     _hos_vecter148  
                     .lword     _hos_vecter149  
                     .lword     _hos_vecter150  
                     .lword     _hos_vecter151  
                     .lword     _hos_vecter152  
                     .lword     _hos_vecter153  
                     .lword     _hos_vecter154  
                     .lword     _hos_vecter155  
                     .lword     _hos_vecter156  
                     .lword     _hos_vecter157  
                     .lword     _hos_vecter158  
                     .lword     _hos_vecter159  
                     .lword     _hos_vecter160  
                     .lword     _hos_vecter161  
                     .lword     _hos_vecter162  
                     .lword     _hos_vecter163  
                     .lword     _hos_vecter164  
                     .lword     _hos_vecter165  
                     .lword     _hos_vecter166  
                     .lword     _hos_vecter167  
                     .lword     _hos_vecter168  
                     .lword     _hos_vecter169  
                     .lword     _hos_vecter170  
                     .lword     _hos_vecter171  
                     .lword     _hos_vecter172  
                     .lword     _hos_vecter173  
                     .lword     _hos_vecter174  
                     .lword     _hos_vecter175  
                     .lword     _hos_vecter176  
                     .lword     _hos_vecter177  
                     .lword     _hos_vecter178  
                     .lword     _hos_vecter179  
                     .lword     _hos_vecter180  
                     .lword     _hos_vecter181  
                     .lword     _hos_vecter182  
                     .lword     _hos_vecter183  
                     .lword     _hos_vecter184  
                     .lword     _hos_vecter185  
                     .lword     _hos_vecter186  
                     .lword     _hos_vecter187  
                     .lword     _hos_vecter188  
                     .lword     _hos_vecter189  
                     .lword     _hos_vecter190  
                     .lword     _hos_vecter191  
                     .lword     _hos_vecter192  
                     .lword     _hos_vecter193  
                     .lword     _hos_vecter194  
                     .lword     _hos_vecter195  
                     .lword     _hos_vecter196  
                     .lword     _hos_vecter197  
                     .lword     _hos_vecter198  
                     .lword     _hos_vecter199  
                     .lword     _hos_vecter200  
                     .lword     _hos_vecter201  
                     .lword     _hos_vecter202  
                     .lword     _hos_vecter203  
                     .lword     _hos_vecter204  
                     .lword     _hos_vecter205  
                     .lword     _hos_vecter206  
                     .lword     _hos_vecter207  
                     .lword     _hos_vecter208  
                     .lword     _hos_vecter209  
                     .lword     _hos_vecter210  
                     .lword     _hos_vecter211  
                     .lword     _hos_vecter212  
                     .lword     _hos_vecter213  
                     .lword     _hos_vecter214  
                     .lword     _hos_vecter215  
                     .lword     _hos_vecter216  
                     .lword     _hos_vecter217  
                     .lword     _hos_vecter218  
                     .lword     _hos_vecter219  
                     .lword     _hos_vecter220  
                     .lword     _hos_vecter221  
                     .lword     _hos_vecter222  
                     .lword     _hos_vecter223  
                     .lword     _hos_vecter224  
                     .lword     _hos_vecter225  
                     .lword     _hos_vecter226  
                     .lword     _hos_vecter227  
                     .lword     _hos_vecter228  
                     .lword     _hos_vecter229  
                     .lword     _hos_vecter230  
                     .lword     _hos_vecter231  
                     .lword     _hos_vecter232  
                     .lword     _hos_vecter233  
                     .lword     _hos_vecter234  
                     .lword     _hos_vecter235  
                     .lword     _hos_vecter236  
                     .lword     _hos_vecter237  
                     .lword     _hos_vecter238  
                     .lword     _hos_vecter239  
                     .lword     _hos_vecter240  
                     .lword     _hos_vecter241  
                     .lword     _hos_vecter242  
                     .lword     _hos_vecter243  
                     .lword     _hos_vecter244  
                     .lword     _hos_vecter245  
                     .lword     _hos_vecter246  
                     .lword     _hos_vecter247  
                     .lword     _hos_vecter248  
                     .lword     _hos_vecter249  
                     .lword     _hos_vecter250  
                     .lword     _hos_vecter251  
                     .lword     _hos_vecter252  
                     .lword     _hos_vecter253  
                     .lword     _hos_vecter254  
                     .lword     _hos_vecter255  
                     .end  
 ;/* ------------------------------------------------------------------------ */  
 ;/* Copyright (C) 1998-2002 by Project HOS                 */  
 ;/* ------------------------------------------------------------------------ */  

sample/rx600/ostimer.c
 /* ------------------------------------------------------------------------ */  
 /* Hyper Operating System V4 サンプルプログラム              */  
 /*  OS用タイマ                               */  
 /*                                     */  
 /*                 Copyright (C) 1998-2002 by Project HOS */  
 /*                 http://sourceforge.jp/projects/hos/   */  
 /* ------------------------------------------------------------------------ */  
 #include <machine.h>  
 #include "kernel.h"  
 #include "iodefine.h"  
 #include "ostimer.h"  
 /* OS用タイマ初期化 */  
 void  
 ostim_init (VP_INT exinf)  
 {  
  /* タイマ初期化 */  
  SYSTEM.PRCR.WORD = 0xA503;  
  MSTP (CMT0) = 0;       /* CMT0モジュールストップ状態解除 */  
  SYSTEM.PRCR.WORD = 0xA500;  
  CMT.CMSTR0.BIT.STR0 = 0;   /* CMT0カウント動作停止 */  
  CMT0.CMCR.WORD = 0x0040;   /* PCLK/8でカウント */  
  CMT0.CMCNT = 0;        /* タイマカウンタ初期化 */  
  CMT0.CMCOR = (UH) (INT) exinf;    /* CMTコンスタントレジスタ設定 */  
  IPR (CMT0, CMI0) = 7;   /* CMT0 CMI0割り込み優先レベル設定 */  
  IEN (CMT0, CMI0) = 1;     /* CMT0 CMI0割込み要求許可 */  
  CMT.CMSTR0.BIT.STR0 = 1;   /* CMT0カウント動作開始 */  
 }  
 /* 割り込みハンドラサンプル */  
 void  
 ostim_hdr (VP_INT exinf)    /* OSタイマ用ハンドラ */  
 {  
  IR(CMT0, CMI0) = 0;  
  isig_tim ();         /* タイムティックの供給 */  
 }  
 /* ------------------------------------------------------------------------ */  
 /* Copyright (C) 1998-2002 by Project HOS                 */  
 /* ------------------------------------------------------------------------ */  

sample/rx600/sci.c
 /* ------------------------------------------------------------------------ */  
 /* RX63N SCI制御                             */  
 /*                                     */  
 /*                 Copyright (C) 1998-2002 by Project HOS */  
 /*                 http://sourceforge.jp/projects/hos/   */  
 /* ------------------------------------------------------------------------ */  
 #include "kernel.h"  
 #include "kernel_id.h"  
 #include "iodefine.h"  
 #include "sci.h"  
 #include "stmfifo.h"  
 /* SCI制御クラス */  
 typedef struct t_sci  
 {  
  ID flgid_snd;  
  ID semid_rcv;  
  T_STMFIFO sndfifo;  
  T_STMFIFO rcvfifo;  
  UB sndbuf[SCI_SND_BUFSZ];  
  UB rcvbuf[SCI_RCV_BUFSZ];  
 }  
 T_SCI;  
 T_SCI scicb_tbl[1];  
 /* 初期化 */  
 void  
 sci_init (VP_INT exinf)  
 {  
  T_SCI *scicb;  
  SYSTEM.PRCR.WORD = 0xA503;  /* */  
  MSTP (SCI2) = 0;       /* Enable module */  
  SYSTEM.PRCR.WORD = 0xA500;  /* */  
  SCI2.SCR.BYTE = 0;      /* シリアルコントロールレジスタクリア */  
  PORT1.PMR.BIT.B3 = 0;  
  PORT1.PMR.BIT.B2 = 0;  
  MPC.PWPR.BIT.B0WI = 0;  
  MPC.PWPR.BIT.PFSWE = 1;  
  MPC.P13PFS.BYTE = 10;     /* P13 TXD2 */  
  MPC.P12PFS.BYTE = 10;     /* P12 RXD2 */  
  MPC.PWPR.BIT.PFSWE = 0;  
  PORT1.PMR.BIT.B3 = 1;  
  PORT1.PMR.BIT.B2 = 1;  
  PORT1.PDR.BIT.B3 = 1;     /* TXD2 is output */  
  PORT1.PDR.BIT.B2 = 0;     /* RXD2 is input */  
  scicb_tbl[0].flgid_snd = FLGID_SCI1_SND;  
  scicb_tbl[0].semid_rcv = SEMID_SCI1_RCV;  
  /* 割り込みレベルの設定 */  
  IPR (SCI2, RXI2) = 1;  
  IEN (SCI2, RXI2) = 1;  
  IEN (SCI2, TXI2) = 1;  
 }  
 /* オープン */  
 ER  
 sci_open (ID id, UB brr)  
 {  
  T_SCI *scicb;  
  INT i;  
  scicb = &scicb_tbl[id - 1];  
  /* 送受信用FIFOバッファ生成 */  
  stmfifo_cre_fifo (&scicb->sndfifo, scicb->sndbuf, SCI_SND_BUFSZ);  
  stmfifo_cre_fifo (&scicb->rcvfifo, scicb->rcvbuf, SCI_RCV_BUFSZ);  
  /* 初期化 */  
  SCI2.SCR.BIT.CKE = 0;     /* シリアルコントロールレジスタクリア */  
  SCI2.SMR.BYTE = 0;      /* シリアルモードレジスタクリア */  
  SCI2.SCMR.BYTE = 0;      /* */  
  SCI2.SEMR.BYTE = 0;      /* */  
  SCI2.BRR = brr;  
  SCI2.SPMR.BIT.CTSE = 0;  
  SCI2.SCR.BIT.TEIE = 0;    /* Enable TEND interrupt flag */  
  SCI2.SCR.BIT.RIE = 1;     /* Enable RX interrupt flag */  
  SCI2.SCR.BIT.RE = 1;     /* Enable */  
  SCI2.SCR.BIT.TIE = 0;     /* Enable TX interrupt flag */  
  SCI2.SCR.BIT.TE = 1;     /* Enable */  
 }  
 /* クローズ */  
 ER  
 sci_close (ID id)  
 {  
  T_SCI *scicb;  
  scicb = &scicb_tbl[id - 1];  
  /* SCIの停止 */  
  SCI2.SCR.BYTE = 0;      /* シリアルコントロールレジスタクリア */  
  /* バッファ破棄 */  
  stmfifo_del_fifo (&scicb->sndfifo);  
  stmfifo_del_fifo (&scicb->rcvfifo);  
 }  
 ER  
 sci_trend_chk (ID id)  
 {  
  T_SCI *scicb;  
  scicb = &scicb_tbl[id - 1];  
  if (stmfifo_emp_chk (&scicb->sndfifo) != E_OK)  
   {  
    return E_OK;  
   }  
  else  
   {  
    return E_TMOUT;  
   }  
 }  
 /* 1文字出力 */  
 ER  
 sci_putc (ID id, UB chr)  
 {  
  T_SCI *scicb;  
  FLGPTN flgptn;  
  UB c ;  
  scicb = &scicb_tbl[id - 1];  
  /* *RX_PEDR |= 0x10; !!!not need? */  
   if (chr == '\0')  
   {  
    return -1;  
   }  
   //SCI2.SCR.BIT.TIE = 0;  
      if(SCI2.SCR.BIT.TIE == 0){  
       if (stmfifo_rcv_chr (&scicb->sndfifo, &c) == E_OK){  
                  SCI2.TDR = c;  
              SCI2.SCR.BIT.TIE = 1;  
           }  
      }  
      while (stmfifo_snd_chr (&scicb->sndfifo, chr) != E_OK)  
   {  
    clr_flg (scicb->flgid_snd, 0xfffe);  
    wai_flg (scicb->flgid_snd, 1, TWF_ANDW, &flgptn);  
   }  
 }  
 /* 文字列出力 */  
 ER_UINT  
 sci_puts (ID id, const UB * str)  
 {  
  char c;  
  T_SCI *scicb;  
  scicb = &scicb_tbl[id - 1];  
  if (*str == '\0')  
   {  
    return -1;  
   }  
   //SCI2.SCR.BIT.TIE = 0;  
    if(SCI2.SCR.BIT.TIE == 0){  
            if (stmfifo_rcv_chr (&scicb->sndfifo, &c) == E_OK){  
                  SCI2.TDR = c;  
               SCI2.SCR.BIT.TIE = 1;  
           }  
      }  
  while (*str)  
   {  
    c = *str++;  
    while (stmfifo_snd_chr (&scicb->sndfifo, c) != E_OK)  
     {  
      clr_flg (scicb->flgid_snd, 0xfffe);  
      wai_flg (scicb->flgid_snd, 1, TWF_ANDW, NULL);  
     }  
       }  
   return 0;  
 }  
 /* 1文字入力 */  
 ER_UINT  
 sci_getc (ID id)  
 {  
  T_SCI *scicb;  
  UB c;  
  scicb = &scicb_tbl[id - 1];  
  wai_sem (scicb->semid_rcv);  
  stmfifo_rcv_chr (&scicb->rcvfifo, &c);  
  return (ER_UINT) c;  
 }  
 /* 文字列入力 */  
 ER_UINT  
 sci_gets (ID id, UB * str)  
 {  
  INT i;  
  UB c;  
  for (i = 0;; i++)  
   {  
    c = sci_getc (id);  
    if (c == '\r')  
     {  
      break;  
     }  
    str[i] = c;  
   }  
  str[i] = '\0';  
  return i;  
 }  
 /* 送信割り込みハンドラ */  
 void  
 sci_snd_hdr (VP_INT exinf)  
 {  
  T_SCI *scicb;  
  ID id;  
  UB c;  
  id = (ID) exinf;  
  scicb = &scicb_tbl[id - 1];  
  /* *RX_PEDR |= 0x01; !!! */  
  /* 送信FIFOから取り出し */  
  if (stmfifo_rcv_chr (&scicb->sndfifo, &c) != E_OK)  
   {  
    /* 送信割り込み停止 */ //問題なければここには来ない  
       SCI2.SCR.BIT.TIE = 0;  
    return;  
   }  
  /* 1キャラクタ送信 */  
  SCI2.TDR = c;  
  /* 送信可能フラグセット */  
  iset_flg (scicb->flgid_snd, 1);  
  if (stmfifo_emp_chk (&scicb->sndfifo) != E_OK)  
   {  
     /* 送信割り込み停止 */  
           SCI2.SCR.BIT.TIE = 0;  
   }  
 }  
 /* 受信割り込みハンドラ */  
 void  
 sci_rcv_hdr (VP_INT exinf)  
 {  
  T_SCI *scicb;  
  ID id;  
  UB c;  
  id = (ID) exinf;  
  scicb = &scicb_tbl[id - 1];  
  /* 1キャラクタ受信 */  
  c = SCI2.RDR;  
  SCI2.SCR.BYTE &= ~0x38;  
  /* 受信FIFOバッファに追加 */  
  if (stmfifo_snd_chr (&scicb->rcvfifo, c) == E_OK)  
   {  
    sig_sem (scicb->semid_rcv);  
   }  
 }  
 /* ------------------------------------------------------------------------ */  
 /* Copyright (C) 1998-2002 by Project HOS                 */  
 /* ------------------------------------------------------------------------ */  

sample/rx600/hwsetup.c
 #include <machine.h>  
 #include "iodefine.h"  
 void  
 HardwareSetup (void)  
 {  
  int i;  
  /* Protect off. */  
  SYSTEM.PRCR.WORD = 0xA50b;  
  /* Wait 2 cycles Extal */  
  SYSTEM.MOSCWTCR.BYTE = 0x0d;  
  /* PLL wait */  
  SYSTEM.PLLWTCR.BYTE = 0x0f;  
  /* PLL OFF */  
  SYSTEM.PLLCR2.BYTE = 0x01;  
  /* x16 @PLL */  
  SYSTEM.PLLCR.WORD = 0x0F00;  
  /* EXTAL ON */  
  SYSTEM.MOSCCR.BYTE = 0x00;  
  /* PLL ON */  
  SYSTEM.PLLCR2.BYTE = 0x00;  
  for (i = 0; i < 0x168; i++)  
   nop ();  
  SYSTEM.SCKCR.LONG = 0x21c21211;    /* OK */  
  SYSTEM.SCKCR2.WORD = 0x0033;  
  SYSTEM.SCKCR3.WORD = 0x0400; /* PLL */  
  SYSTEM.PRCR.WORD = 0xA500;  
 /* PA0 */  
  PORTA.PMR.BIT.B0 = 0;  
  PORTA.PDR.BIT.B0 = 1;  
  PORTA.PODR.BIT.B0 = 1;  
 /* PA1 */  
  PORTA.PMR.BIT.B1 = 0;  
  PORTA.PDR.BIT.B1 = 1;  
  PORTA.PODR.BIT.B1 = 0;  
 /* PA2 */  
  PORTA.PMR.BIT.B2 = 0;  
  PORTA.PDR.BIT.B2 = 1;  
  PORTA.PODR.BIT.B2 = 0;  
 /* PA6 */  
  PORTA.PMR.BIT.B6 = 0;  
  PORTA.PDR.BIT.B6 = 1;  
  PORTA.PODR.BIT.B6 = 0;  
 /* PA7 */  
  PORTA.PMR.BIT.B7 = 0;  
  PORTA.PDR.BIT.B7 = 0;  
 }  
sample/rx600/intprg.c
 /***********************************************************************/  
 /*                                   */  
 /* FILE    :intprg.c                       */  
 /* DATE    :Wed, Aug 01, 2012                   */  
 /* DESCRIPTION :Interrupt Program                   */  
 /* CPU TYPE  :RX63N                         */  
 /*                                   */  
 /* This file is generated by Renesas Project Generator (Ver.4.52).  */  
 /* NOTE:THIS IS A TYPICAL EXAMPLE.                  */  
 /*                                   */  
 /***********************************************************************/  
 /************************************************************************  
 *  
 * Device   : RX/RX600/RX63N  
 *  
 * File Name : intprg.c  
 *  
 * Abstract  : Interrupt Program.  
 *  
 * History  : 0.10 (2011-02-21) [Hardware Manual Revision : 0.01]  
 *  
 * NOTE    : THIS IS A TYPICAL EXAMPLE.  
 *  
 * Copyright (C) 2011 Renesas Electronics Corporation.  
 * and Renesas Solutions Corp.  
 *  
 *********************************************************************/  
 #include <machine.h>  
 #include "vect.h"  
 #pragma section IntPRG  
 // Exception(Supervisor Instruction)  
 void Excep_SuperVisorInst(void){/* brk(); */}  
 // Exception(Undefined Instruction)  
 void Excep_UndefinedInst(void){/* brk(); */}  
 // Exception(Floating Point)  
 void Excep_FloatingPoint(void){/* brk(); */}  
 // NMI  
 void NonMaskableInterrupt(void){/* brk(); */}  
 // Dummy  
 void Dummy(void){/* brk(); */}  
sample/rx600/resetprg.c
 /***********************************************************************/  
 /*                                   */  
 /* FILE    :resetprg.c                      */  
 /* DATE    :Wed, Aug 01, 2012                   */  
 /* DESCRIPTION :Reset Program                     */  
 /* CPU TYPE  :RX63N                         */  
 /*                                   */  
 /* This file is generated by Renesas Project Generator (Ver.4.52).  */  
 /* NOTE:THIS IS A TYPICAL EXAMPLE.                  */  
 /*                                   */  
 /***********************************************************************/  
 /*********************************************************************  
 *  
 * Device   : RX/RX600  
 *  
 * File Name : resetprg.c  
 *  
 * Abstract  : Reset Program.  
 *  
 * History  : 1.00 (2009-08-07)  
 *      : 1.10 (2011-02-21)  
 *  
 * NOTE    : THIS IS A TYPICAL EXAMPLE.  
 *  
 * Copyright (C) 2009 (2011) Renesas Electronics Corporation.  
 * and Renesas Solutions Corp.  
 *  
 *********************************************************************/  
 #include     <machine.h>  
 #include     <_h_c_lib.h>  
 //#include   <stddef.h>                   // Remove the comment when you use errno  
 //#include   <stdlib.h>                   // Remove the comment when you use rand()  
 #include     "typedefine.h" // Define Types  
 #include     "stacksct.h"  // Stack Sizes (Interrupt and User)  
 #ifdef __cplusplus  
 extern "C"  
 {  
 #endif  
  void PowerON_Reset (void);  
  void main (void);  
 #ifdef __cplusplus  
 }  
 #endif  
 //#ifdef __cplusplus              // Use SIM I/O  
 //extern "C" {  
 //#endif  
 //extern void _INIT_IOLIB(void);  
 //extern void _CLOSEALL(void);  
 //#ifdef __cplusplus  
 //}  
 //#endif  
 #define PSW_init 0x00030000  // PSW bit pattern  
 #define FPSW_init 0x00000000  // FPSW bit base pattern  
 //extern void srand(_UINT);       // Remove the comment when you use rand()  
 //extern _SBYTE *_s1ptr;                // Remove the comment when you use strtok()  
 #ifdef __cplusplus       // Use Hardware Setup  
 extern "C"  
 {  
 #endif  
  extern void HardwareSetup (void);  
 #ifdef __cplusplus  
 }  
 #endif  
 //#ifdef __cplusplus          // Remove the comment when you use global class object  
 //extern "C" {                 // Sections C$INIT and C$END will be generated  
 //#endif  
 //extern void _CALL_INIT(void);  
 //extern void _CALL_END(void);  
 //#ifdef __cplusplus  
 //}  
 //#endif  
 //unsigned long kernel_int_sp;  
 #pragma section ResetPRG    // output PowerON_Reset to PResetPRG section  
 #pragma entry PowerON_Reset  
 void  
 PowerON_Reset (void)  
 {  
  set_intb (__sectop ("C$VECT"));  
 #ifdef __ROZ          // Initialize FPSW  
 #define _ROUND 0x00000001    // Let FPSW RMbits=01 (round to zero)  
 #else  
 #define _ROUND 0x00000000    // Let FPSW RMbits=00 (round to nearest)  
 #endif  
 #ifdef __DOFF  
 #define _DENOM 0x00000100    // Let FPSW DNbit=1 (denormal as zero)  
 #else  
 #define _DENOM 0x00000000    // Let FPSW DNbit=0 (denormal as is)  
 #endif  
 //   set_fpsw(FPSW_init | _ROUND | _DENOM);  
  _INITSCT ();  
 //   _INIT_IOLIB();                 // Use SIM I/O  
 //   errno=0;                        // Remove the comment when you use errno  
 //   srand((_UINT)1);                    // Remove the comment when you use rand()  
 //   _s1ptr=NULL;                  // Remove the comment when you use strtok()  
  HardwareSetup ();       // Use Hardware Setup  
  nop ();  
 //   _CALL_INIT();                  // Remove the comment when you use global class object  
  set_psw (PSW_init);      // Set Ubit & Ibit for PSW  
 //   chg_pmusr();                  // Remove the comment when you need to change PSW PMbit (SuperVisor->User)  
  main ();  
 //   _CLOSEALL();                  // Use SIM I/O  
 //   _CALL_END();                  // Remove the comment when you use global class object  
  brk ();  
 }  
sample/rx600/sample.c
 /* ------------------------------------------------------------------------ */  
 /* Hyper Operating System V4 サンプルプログラム              */  
 /*  いわゆる哲学者の食事の問題                       */  
 /*                                     */  
 /*                 Copyright (C) 1998-2002 by Project HOS */  
 /*                 http://sourceforge.jp/projects/hos/   */  
 /* ------------------------------------------------------------------------ */  
 #include <stdio.h>  
 #include <stdlib.h>  
 #include "kernel.h"  
 #include "kernel_id.h"  
 #include "user_id.h"  
 #include "iodefine.h"  
 #include "sci.h"  
 #include "sample.h"  
 #define SCIID               ID_SCI1  
 #define LEFT_FORK(id)     ((id) % 5 + 1)  
 #define RIGHT_FORK(id)     (id)  
 void SetLed (INT id);      /* 対応のLED点灯 */  
 void ResetLed (INT id);     /* 対応LDEの消灯 */  
 int led = 0;  
 /* メイン関数 */  
 int  
 main ()  
 {  
  /* I/O の初期化 */  
  sci_init (1);  
  sci_open (1, 12);  
  /* HOS-V4 の開始 */  
  sta_hos ();  
  chg_imsk (0);  
  hospac_ena_int ();  
  return 0;  
 }  
 /* ATT_INI 登録の関数 */  
 void  
 SampleInitialize (VP_INT exinf)  
 {  
  /* タスク起動 */  
  act_tsk (TSKID_PHILOSOPHER1);  
  act_tsk (TSKID_PHILOSOPHER2);  
  act_tsk (TSKID_PHILOSOPHER3);  
  act_tsk (TSKID_PHILOSOPHER4);  
  act_tsk (TSKID_PHILOSOPHER5);  
 }  
 void  
 ELLOOP (VP_INT exinf)  
 {  
  while (1);  
 }  
 /* 哲学者タスク */  
 void  
 PhilosopherTask (VP_INT exinf)  
 {  
  INT id;  
  INT i;  
  id = (INT) exinf;  
  dly_tsk(10);  
  wai_sem( SEMID_SCI1_SND );  
  sci_puts(1, "abcd1234sssssssssssssssssss ");  
  sci_putc(1, 0x30|(UB)id);  
  sci_puts(1,    " sssssssssssssssssss1234\r\n");  
  led++;  
  sig_sem(SEMID_SCI1_SND);  
  /* 超お馬鹿アルゴリズム */  
  for (;;)  
   {  
    /* 適当な時間悩んでみる */  
    for (i = rand () % 10 + 5; i > 0; i--)  
     {  
      /* 点滅させる */  
      SetLed (id);  
      dly_tsk (100);  
      ResetLed (id);  
      dly_tsk (100);  
     }  
    /* 左右のフォークを取る */  
    for (;;)  
     {  
      wai_sem (LEFT_FORK (id));  
      if (pol_sem (RIGHT_FORK (id)) == E_OK)  
       {  
        break;  
       }  
      sig_sem (LEFT_FORK (id));  
      dly_tsk ((rand () % 10 + 1) * 10);  /* 適当に待つ */  
     }  
    /* お食事中 */  
    SetLed (id);       /* 点灯させる */  
    dly_tsk (1000);  
    ResetLed (id);  
    /* フォークを放す */  
    sig_sem (LEFT_FORK (id));  
    sig_sem (RIGHT_FORK (id));  
   }  
 }  
 void  
 cyc_test (VP_INT exinf)  
 {  
  static char blink;  
  blink++;  
  wai_sem (SEMID_SYSCS);  
  PORTA.PODR.BIT.B6 = blink;  
  sig_sem (SEMID_SYSCS);  
 }  
 /* 対応のLED点灯 */  
 void  
 SetLed (INT id)  
 {  
  wai_sem (SEMID_SYSCS);  
  PORTA.PODR.BYTE &= ~(0x01 << (id - 1));  
  sig_sem (SEMID_SYSCS);  
 }  
 /* 対応LDEの消灯 */  
 void  
 ResetLed (INT id)  
 {  
  wai_sem (SEMID_SYSCS);  
  PORTA.PODR.BYTE |= (0x01 << (id - 1));  
  sig_sem (SEMID_SYSCS);  
 }  
 /* ------------------------------------------------------------------------ */  
 /* Copyright (C) 1998-2002 by Project HOS                 */  
 /* ------------------------------------------------------------------------ */  
その他
sample/rx600/dbsct.c HEWで生成したもの
sample/rx600/vect.c HEWで生成したもの
sample/rx600/vecttbl.c HEWで生成したもの
sample/rx600/iodefine.h HEWで生成したもの
sample/rx600/stacksct.h HEWで生成したもの
sample/rx600/typedefine.h HEWで生成したもの
sample/rx600/ostimer.h そのまま
sample/rx600/sci.h そのまま
sample/rx600/stmfifot.c そのまま
sample/rx600/stmfifot.h そのまま
sample/rx600/crt0.s 削除