tomoyuki-nakabayashi / Rustemu86

Apache License 2.0
5 stars 0 forks source link

RISC-V命令セットサポートの準備 #29

Closed tomoyuki-nakabayashi closed 6 years ago

tomoyuki-nakabayashi commented 6 years ago

ISAを複数種類サポートできるようにしよう。

tomoyuki-nakabayashi commented 6 years ago
#include <stdint.h>
/* UART0 address on riscv-qemu 'virt' machine */
volatile uint8_t *uart16550 = (uint8_t *)0x10000000;
volatile uint32_t *testfinisher = (uint32_t *)0x100000;

enum {
    UART_REG_QUEUE     = 0,
    UART_REG_LINESTAT  = 5,
    UART_REG_STATUS_RX = 0x01,
    UART_REG_STATUS_TX = 0x20
};

static inline void display_string(uint8_t string){
  while((uart16550[UART_REG_LINESTAT] & UART_REG_STATUS_TX) == 0);
  uart16550[UART_REG_QUEUE] = string;
}

int main(){
  char* str = "hello world\n";
  while (*str != '\0') {
    display_string(*str);
    str++;
  }
  *testfinisher = 0x5555;

  return 0;
}
80000000 <reset_vector>:
80000000:   0040006f            j   80000004 <do_reset>

80000004 <do_reset>:
80000004:   00000093            li  ra,0
80000008:   00000113            li  sp,0
8000000c:   00000193            li  gp,0
80000010:   00000213            li  tp,0
80000014:   00000293            li  t0,0
80000018:   00000313            li  t1,0
8000001c:   00000393            li  t2,0
80000020:   00000413            li  s0,0
80000024:   00000493            li  s1,0
80000028:   00000513            li  a0,0
8000002c:   00000593            li  a1,0
80000030:   00000613            li  a2,0
80000034:   00000693            li  a3,0
80000038:   00000713            li  a4,0
8000003c:   00000793            li  a5,0
80000040:   00000813            li  a6,0
80000044:   00000893            li  a7,0
80000048:   00000913            li  s2,0
8000004c:   00000993            li  s3,0
80000050:   00000a13            li  s4,0
80000054:   00000a93            li  s5,0
80000058:   00000b13            li  s6,0
8000005c:   00000b93            li  s7,0
80000060:   00000c13            li  s8,0
80000064:   00000c93            li  s9,0
80000068:   00000d13            li  s10,0
8000006c:   00000d93            li  s11,0
80000070:   00000e13            li  t3,0
80000074:   00000e93            li  t4,0
80000078:   00000f13            li  t5,0
8000007c:   00000f93            li  t6,0
80000080:   34001073            csrw    mscratch,zero
80000084:   00002117            auipc   sp,0x2
80000088:   efc10113            addi    sp,sp,-260 # 80001f80 <stacks+0xf80>
8000008c:   05c000ef            jal ra,800000e8 <main>
80000090:   10500073            wfi

80000094 <display_string>:
80000094:   fe010113            addi    sp,sp,-32
80000098:   00812e23            sw  s0,28(sp)
8000009c:   02010413            addi    s0,sp,32
800000a0:   00050793            mv  a5,a0
800000a4:   fef407a3            sb  a5,-17(s0)
800000a8:   00000013            nop
800000ac:   800007b7            lui a5,0x80000
800000b0:   16c7a783            lw  a5,364(a5) # 8000016c <pulp__FC+0x8000016d>
800000b4:   00578793            addi    a5,a5,5
800000b8:   0007c783            lbu a5,0(a5)
800000bc:   0ff7f793            andi    a5,a5,255
800000c0:   0207f793            andi    a5,a5,32
800000c4:   fe0784e3            beqz    a5,800000ac <display_string+0x18>
800000c8:   800007b7            lui a5,0x80000
800000cc:   16c7a783            lw  a5,364(a5) # 8000016c <pulp__FC+0x8000016d>
800000d0:   fef44703            lbu a4,-17(s0)
800000d4:   00e78023            sb  a4,0(a5)
800000d8:   00000013            nop
800000dc:   01c12403            lw  s0,28(sp)
800000e0:   02010113            addi    sp,sp,32
800000e4:   00008067            ret

800000e8 <main>:
800000e8:   fe010113            addi    sp,sp,-32
800000ec:   00112e23            sw  ra,28(sp)
800000f0:   00812c23            sw  s0,24(sp)
800000f4:   02010413            addi    s0,sp,32
800000f8:   800007b7            lui a5,0x80000
800000fc:   15c78793            addi    a5,a5,348 # 8000015c <pulp__FC+0x8000015d>
80000100:   fef42623            sw  a5,-20(s0)
80000104:   0200006f            j   80000124 <main+0x3c>
80000108:   fec42783            lw  a5,-20(s0)
8000010c:   0007c783            lbu a5,0(a5)
80000110:   00078513            mv  a0,a5
80000114:   f81ff0ef            jal ra,80000094 <display_string>
80000118:   fec42783            lw  a5,-20(s0)
8000011c:   00178793            addi    a5,a5,1
80000120:   fef42623            sw  a5,-20(s0)
80000124:   fec42783            lw  a5,-20(s0)
80000128:   0007c783            lbu a5,0(a5)
8000012c:   fc079ee3            bnez    a5,80000108 <main+0x20>
80000130:   800007b7            lui a5,0x80000
80000134:   1707a783            lw  a5,368(a5) # 80000170 <pulp__FC+0x80000171>
80000138:   00005737            lui a4,0x5
8000013c:   55570713            addi    a4,a4,1365 # 5555 <reset_vector-0x7fffaaab>
80000140:   00e7a023            sw  a4,0(a5)
80000144:   00000793            li  a5,0
80000148:   00078513            mv  a0,a5
8000014c:   01c12083            lw  ra,28(sp)
80000150:   01812403            lw  s0,24(sp)
80000154:   02010113            addi    sp,sp,32
80000158:   00008067            ret
tomoyuki-nakabayashi commented 6 years ago

このissue自体はclose。