int test11_1_main(int argc, char *argv[]) {
  char *p;
  int size;

  puts("test11_1 started.\n");

  /* 静的領域を受信 */
  puts("test11_1 recv in.\n");
  kz_recv(MSGBOX_ID_MSGBOX1, &size, &p);
  puts("test11_1 recv out.\n");
  puts(p);

  /* 動的に確保した領域を受信 */
  puts("test11_1 recv in.\n");
  kz_recv(MSGBOX_ID_MSGBOX1, &size, &p);
  puts("test11_1 recv out.\n");
  puts(p);
  kz_kmfree(p);

  /* 静的領域を送信 */
  puts("test11_1 send in.\n");
  kz_send(MSGBOX_ID_MSGBOX2, 15, "static memory\n");
  puts("test11_1 send out.\n");

  /* 動的領域を送信 */
  p = kz_kmalloc(18);
  strcpy(p, "allocated memory\n");
  puts("test11_1 send in.\n");
  kz_send(MSGBOX_ID_MSGBOX2, 18, p);
  pust("test11_1 send out.\n");

  puts("test11_1 exit.\n");

  return 0;
}
Exemplo n.º 2
0
int test11_2_main(
	int argc,
	char* argv[]
	)
{
	char* p;
	int size;

	puts("test11_2 started.\n");

	puts("test11_2 send in.\n");
	kz_send(MSGBOX_ID_MSGBOX1, 15, "static memory\n");
	puts("test11_2 send out.\n");

	p = kz_kmalloc(18);
	strcpy(p, "allocated memory\n");
	puts("test11_2 send in.\n");
	kz_send(MSGBOX_ID_MSGBOX1, 18, p);
	puts("test11_2 send out.\n");

	puts("test11_2 recv in.\n");
	kz_recv(MSGBOX_ID_MSGBOX2, &size, &p);
	puts("test11_2 recv out.\n");
	puts(p);

	puts("test11_2 recv in.\n");
	kz_recv(MSGBOX_ID_MSGBOX2, &size, &p);
	puts("test11_2 recv out.\n");
	puts(p);
	kz_kmfree(p);

	puts("test11_2 exit.\n");

	return 0;
}
Exemplo n.º 3
0
static void arp_flush(int count)
{
  struct netbuf *pkt;
  struct addrset *addr;

  while (1) {
    kz_recv(MSGBOX_ID_ARPPKTLIST, NULL, (void *)&pkt);
    if (pkt == NULL) {
      kz_send(MSGBOX_ID_ARPPKTLIST, 0, NULL);
      break;
    }

    addr = arp_getaddr(pkt->option.ethernet.send.dst_ipaddr);
    if (addr) {
      addr = (count == 0) ? NULL : addr;
      count = (count > 0) ? (count - 1) : count;
    }

    if (addr == NULL) {
      kz_send(MSGBOX_ID_ARPPKTLIST, 0, (char *)pkt);
      continue;
    }

    memcpy(pkt->option.ethernet.send.dst_macaddr, addr->macaddr, MACADDR_SIZE);

    pkt->cmd = ETHERNET_CMD_SEND;
    kz_send(MSGBOX_ID_ETHPROC, 0, (char *)pkt);
  }
}
Exemplo n.º 4
0
int command_main(int argc, char *argv[])
{
  char *p;
  int size;

  send_use(SERIAL_DEFAULT_DEVICE);

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    p[size] = '\0';

    if (!strncmp(p, "echo", 4)) { /* echoコマンド */
      send_write(p + 4); /* echoに続く文字列を出力する */
      send_write("\n");
    } else {
      send_write("unknown.\n");
    }

    kz_kmfree(p);
  }

  return 0;
}
Exemplo n.º 5
0
int command_main(int argc, char * argv[])
{
  unsigned int size;
  char * str;

  send_use(SERIAL_DEFAULT_DEVICE);

  while(True) {
    send_write("command> ");

    kz_recv(MSGBOX_ID_CONSINPUT, &size, &str);
    str[size] = '\0';

    if( strncmp((cString)str, "echo ", 5) == Same ) {
      send_write((str + 5)); send_write("\n");
    }
    else {
      send_write("unkown\n");
    }

    kz_kmfree(str);
  }

  return EXIT_SUCCESS;
}
Exemplo n.º 6
0
int clock_main(int argc, char *argv[])
{
  send_start(3000);

  while (1) {
    kz_recv(MSGBOX_ID_TIMEXPIRE, NULL, NULL);
    send_write("ready.\n");
    send_start(3000);
  }

  return 0;
}
Exemplo n.º 7
0
int task_display(int argc, char *argv[])
{
  int size;
  char *p;

  while (1) {
    kz_recv(MSGBOX_ID_DISPLAY, &size, &p);
    display_cmdproc(p);
  }

  return 0;
}
Exemplo n.º 8
0
int func_read(char *buf, int cnt)
{
  int i;
  for (i = 0; i < cnt; i++) {
    char *p;
    int size;
    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    buf[i] = p[0];
    kz_kmfree(p);
  }
  return 0;
}
Exemplo n.º 9
0
int command_main(int argc, char *argv[])
{
  char *p;
  int size;
  int num = 0;
  char *cmd[COMMAND_WORD_NUM];
  int cmd_len = 0;
  int i, j;

  send_use(SERIAL_DEFAULT_DEVICE);
  command_init( cmd );
  file_init();

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コマンド格納バッファを0クリアする */
    for( j = 0; j < COMMAND_WORD_NUM; j++ ){
      memset( cmd[j], 0, COMMAND_WORD_LENGTH );
    }

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    p[size] = '\0';

    /* 入力文字列を分解する */
    if( ( num = command_split( p, cmd ) ) == 0 ){
      send_write("input nothing\n");
      continue;
    }

    /* コマンドの実行 */
    cmd_len = strlen( cmd[0] );
    for( i = 0; command_table[i].cmd != NULL; i++ ){
      if( !strncmp( cmd[0],
                    command_table[i].cmd,
                    (cmd_len>command_table[i].size?cmd_len:command_table[i].size) ) ){
	command_table[i].func( num, cmd );
	break;
      }
    }
    if( command_table[i].cmd == NULL ){
      send_write("unknown.\n");
    }
    kz_kmfree(p);
  }

  command_terminate( cmd );

  return 0;
}
Exemplo n.º 10
0
int test11_1_main(int argc, char *argv[])
{
  char *p;
  int size;

  puts("test11_1 started.\n");

  /* 静的領域をメッセージで受信 */
  puts("test11_1 recv in.\n");
  kz_recv(MSGBOX_ID_MSGBOX1, &size, &p); /* 受信 */
  puts("test11_1 recv out.\n");
  puts(p);

  /* 動的に獲得した領域をメッセージで受信 */
  puts("test11_1 recv in.\n");
  kz_recv(MSGBOX_ID_MSGBOX1, &size, &p); /* 受信 */
  puts("test11_1 recv out.\n");
  puts(p);
  kz_kmfree(p); /* メモリ解放 */

  /* 静的領域をメッセージで送信 */
  puts("test11_1 send in.\n");
  kz_send(MSGBOX_ID_MSGBOX2, 15, "static memory\n"); /* 送信 */
  puts("test11_1 send out.\n");

  /* 動的に獲得した領域をメッセージで送信 */
  p = kz_kmalloc(18); /* メモリ獲得 */
  strcpy(p, "allocated memory\n");
  puts("test11_1 send in.\n");
  kz_send(MSGBOX_ID_MSGBOX2, 18, p); /* 送信 */
  puts("test11_1 send out.\n");
  /* メモリ解放は受信側で行うので,ここでは不要 */

  puts("test11_1 exit.\n");

  return 0;
}
Exemplo n.º 11
0
int netdrv_main(int argc, char *argv[])
{
  struct netbuf *buf;

  netdrv_init();
  kz_setintr(SOFTVEC_TYPE_ETHINTR, netdrv_intr); /* 割込みハンドラ設定 */

  while (1) {
    kz_recv(MSGBOX_ID_NETPROC, NULL, (char **)&buf);
    netdrv_proc(buf);
    kz_kmfree(buf);
  }

  return 0;
}
Exemplo n.º 12
0
int command_main(int argc, char *argv[])
{
  char *p;
  int size;
  long prev_time;

  send_use(SERIAL_DEFAULT_DEVICE);

  while (1) {
    send_write("command> "); /* プロンプト表示 */

    /* コンソールからの受信文字列を受け取る */
    kz_recv(MSGBOX_ID_CONSINPUT, &size, &p);
    if (p == NULL) {
      send_write("expired.\n");
      continue;
    }
    p[size] = '\0';

    if (!strncmp(p, "echo", 4)) { /* echoコマンド */
      send_write(p + 4); /* echoに続く文字列を出力する */
      send_write("\n");
    } else if (!strncmp(p, "timer", 5)) { /* timerコマンド */
      send_write("timer start.\n");
      send_start(1000);
    } else if (!strncmp(p, "ping", 4)) { /* pingコマンド */
      send_write("ping start.\n");
      send_icmp();
    } else if (!strncmp(p, "tftp", 4)) { /* tftpコマンド */
      send_write("tftp start.\n");
      send_tftp();
    } else if (!strncmp(p, "debug", 5)) { /* デバッガ起動 */
      set_debug_traps();
      force_break();
    } else if (!strncmp(p, "call", 4)) { /* ダミー関数の呼び出し */
      send_write(func(p + 4));
    } else if (!strncmp(p, "get", 3)) { /* get */
      prev_time = get_time();
      putxval(prev_time, 8); puts("\n");
    } else {
      send_write("unknown.\n");
    }

    kz_kmfree(p);
  }

  return 0;
}
Exemplo n.º 13
0
int arp_main(int argc, char *argv[])
{
  struct netbuf *buf;
  int ret;

  kz_send(MSGBOX_ID_ARPADRLIST, 0, NULL);
  kz_send(MSGBOX_ID_ARPPKTLIST, 0, NULL);

  while (1) {
    kz_recv(MSGBOX_ID_ARPPROC, NULL, (void *)&buf);
    ret = arp_proc(buf);
    if (!ret) kz_kmfree(buf);
  }

  return 0;
}
Exemplo n.º 14
0
static struct addrset *arp_getaddr(uint32 ipaddr)
{
  struct addrset *addr, *ret = NULL;
  while (1) {
    kz_recv(MSGBOX_ID_ARPADRLIST, NULL, (void *)&addr);
    if (addr == NULL) { /* 終端まできた */
      kz_send(MSGBOX_ID_ARPADRLIST, 0, NULL);
      break;
    }
    if (addr->ipaddr == ipaddr) {
      ret = addr;
    }
    kz_send(MSGBOX_ID_ARPADRLIST, 0, (char *)addr);
  }
  return ret;
}
Exemplo n.º 15
0
int httpd_main(int argc, char *argv[])
{
  char *p = NULL, *r;
  char *buffer;
  int number = 0, ret;
  struct netbuf *buf;

  send_accept();

  buffer = kz_kmalloc(DEFAULT_NETBUF_SIZE);

  while (1) {
    kz_recv(MSGBOX_ID_HTTPD, NULL, (void *)&buf);

    switch (buf->cmd) {
    case TCP_CMD_ESTAB:
      number = buf->option.tcp.establish.number;
      p = buffer;
      break;

    case TCP_CMD_CLOSE:
      number = 0;
      send_accept();
      break;

    case TCP_CMD_RECV:
      memcpy(p, buf->top, buf->size);
      p += buf->size;
      *p = '\0';

      r = strchr(buffer, '\n');
      if (r) {
	*r = '\0';
	r++;
	ret = parse(number, buffer);
	memmove(buffer, r, p - r + 1);
	p -= (r - buffer);
	if (ret) send_close(number);
      }
      break;
    }

    kz_kmfree(buf);
  }

  return 0;
}
Exemplo n.º 16
0
int ethernet_main(int argc, char *argv[])
{
    struct netbuf *buf;
    int ret;

    buf = kz_kmalloc(sizeof(*buf));
    buf->cmd = NETDRV_CMD_USE;
    kz_send(MSGBOX_ID_NETPROC, 0, (char *)buf);

    while (1) {
        kz_recv(MSGBOX_ID_ETHPROC, NULL, (char **)&buf);
        ret = ethernet_proc(buf);
        if (!ret) kz_kmfree(buf);
    }

    return 0;
}
Exemplo n.º 17
0
int consdrv_main(int argc, char *argv[])
{
  int size, index;
  kz_thread_id_t id;
  char *p;

  consdrv_init();
  kz_setintr(SOFTVEC_TYPE_SERINTR, consdrv_intr); /* 割込みハンドラ設定 */

  while (1) {
    id = kz_recv(MSGBOX_ID_CONSOUTPUT, &size, &p);
    index = p[0] - '0';
    consdrv_command(&consreg[index], id, index, size - 1, p + 1);
    kz_kmfree(p);
  }

  return 0;
}
Exemplo n.º 18
0
int icmp_main(int argc, char *argv[])
{
  struct netbuf *buf;
  int ret;

  buf = kz_kmalloc(sizeof(*buf));
  buf->cmd = IP_CMD_REGPROTO;
  buf->option.ip.regproto.protocol = IP_PROTOCOL_ICMP;
  buf->option.ip.regproto.cmd      = ICMP_CMD_RECV;
  buf->option.ip.regproto.id       = MSGBOX_ID_ICMPPROC;
  kz_send(MSGBOX_ID_IPPROC, 0, (char *)buf);

  while (1) {
    kz_recv(MSGBOX_ID_ICMPPROC, NULL, (void *)&buf);
    ret = icmp_proc(buf);
    if (!ret) kz_kmfree(buf);
  }

  return 0;
}