URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
Compare Revisions
- This comparison shows the changes necessary to convert path
/eco32/trunk/monitor
- from Rev 182 to Rev 183
- ↔ Reverse comparison
Rev 182 → Rev 183
/monitor/common/sctio-ser.s
File deleted
/monitor/common/sctio-ctl.s
File deleted
/monitor/common/dskctl.s
0,0 → 1,137
; |
; dskctl.s -- disk made available by disk controller |
; |
|
;*************************************************************** |
|
.set dskbase,0xF0400000 ; disk base address |
.set dskctrl,0 ; control register |
.set dskcnt,4 ; count register |
.set dsksct,8 ; sector register |
.set dskcap,12 ; capacity register |
.set dskbuf,0x00080000 ; disk buffer |
|
.set ctrlstrt,0x01 ; start bit |
.set ctrlien,0x02 ; interrupt enable bit |
.set ctrlwrt,0x04 ; write bit |
.set ctrlerr,0x08 ; error bit |
.set ctrldone,0x10 ; done bit |
.set ctrlrdy,0x20 ; ready bit |
|
.set sctsize,512 ; sector size in bytes |
|
.set retries,1000000 ; retries to get disk ready |
|
.export dskinit ; initialize disk |
.export dskcapctl ; determine disk capacity |
.export dskioctl ; do disk I/O |
|
;*************************************************************** |
|
.code |
.align 4 |
|
dskinit: |
jr $31 |
|
dskcapctl: |
add $8,$0,retries ; set retry count |
add $9,$0,dskbase |
dskcap1: |
ldw $10,$9,dskctrl |
and $10,$10,ctrlrdy ; ready? |
bne $10,$0,dskcapok ; yes - jump |
sub $8,$8,1 |
bne $8,$0,dskcap1 ; try again |
add $2,$0,0 ; no disk found |
j dskcapx |
dskcapok: |
ldw $2,$9,dskcap ; get disk capacity |
dskcapx: |
jr $31 |
|
dskioctl: |
sub $29,$29,24 |
stw $31,$29,20 |
stw $16,$29,16 |
stw $17,$29,12 |
stw $18,$29,8 |
stw $19,$29,4 |
stw $20,$29,0 |
add $16,$4,$0 ; command |
add $17,$5,$0 ; sector number |
add $18,$6,0xC0000000 ; memory address, virtualized |
add $19,$7,$0 ; number of sectors |
|
add $8,$0,'r' |
beq $16,$8,dskrd |
add $8,$0,'w' |
beq $16,$8,dskwr |
add $2,$0,0xFF ; illegal command |
j dskx |
|
dskrd: |
add $2,$0,$0 ; return ok |
beq $19,$0,dskx ; if no (more) sectors |
add $8,$0,dskbase |
add $9,$0,1 |
stw $9,$8,dskcnt ; number of sectors |
stw $17,$8,dsksct ; sector number on disk |
add $9,$0,ctrlstrt |
stw $9,$8,dskctrl ; start command |
dskrd1: |
ldw $2,$8,dskctrl |
and $9,$2,ctrldone ; done? |
beq $9,$0,dskrd1 ; no - wait |
and $9,$2,ctrlerr ; error? |
bne $9,$0,dskx ; yes - leave |
add $8,$0,dskbase + dskbuf ; transfer data |
add $9,$0,sctsize |
dskrd2: |
ldw $10,$8,0 ; from disk buffer |
stw $10,$18,0 ; to memory |
add $8,$8,4 |
add $18,$18,4 |
sub $9,$9,4 |
bne $9,$0,dskrd2 |
add $17,$17,1 ; increment sector number |
sub $19,$19,1 ; decrement number of sectors |
j dskrd ; next sector |
|
dskwr: |
add $2,$0,$0 ; return ok |
beq $19,$0,dskx ; if no (more) sectors |
add $8,$0,dskbase + dskbuf ; transfer data |
add $9,$0,sctsize |
dskwr1: |
ldw $10,$18,0 ; from memory |
stw $10,$8,0 ; to disk buffer |
add $18,$18,4 |
add $8,$8,4 |
sub $9,$9,4 |
bne $9,$0,dskwr1 |
add $8,$0,dskbase |
add $9,$0,1 |
stw $9,$8,dskcnt ; number of sectors |
stw $17,$8,dsksct ; sector number on disk |
add $9,$0,ctrlwrt | ctrlstrt |
stw $9,$8,dskctrl ; start command |
dskwr2: |
ldw $2,$8,dskctrl |
and $9,$2,ctrldone ; done? |
beq $9,$0,dskwr2 ; no - wait |
and $9,$2,ctrlerr ; error? |
bne $9,$0,dskx ; yes - leave |
add $17,$17,1 ; increment sector number |
sub $19,$19,1 ; decrement number of sectors |
j dskwr ; next sector |
|
dskx: |
ldw $20,$29,0 |
ldw $19,$29,4 |
ldw $18,$29,8 |
ldw $17,$29,12 |
ldw $16,$29,16 |
ldw $31,$29,20 |
add $29,$29,24 |
jr $31 |
/monitor/common/dskser.s
0,0 → 1,200
; |
; dskser.s -- disk made available by serial interface |
; |
|
;*************************************************************** |
|
.export dskcapser ; determine disk capacity |
.export dskioser ; do disk I/O |
|
.import ser1in |
.import ser1out |
.import ser1inchk |
.import puts |
|
; constants for communication with disk server |
.set SYN,0x16 ; to initiate the three-way handshake |
.set ACK,0x06 ; acknowledgement for handshake |
.set RESULT_OK,0x00 ; server successfully executed cmd |
; everything else means error |
|
.set WAIT_DELAY,800000 ; count for delay loop |
|
;*************************************************************** |
|
.code |
.align 4 |
|
dskcapser: |
sub $29,$29,16 |
stw $16,$29,0 |
stw $17,$29,4 |
stw $18,$29,8 |
stw $31,$29,12 |
add $4,$0,trymsg ; say what we are doing |
jal puts |
add $18,$0,$0 ; capacity == 0 if disk not present |
add $16,$0,10 ; 10 tries to get a connection |
handshake1: |
sub $16,$16,1 |
add $4,$0,SYN |
jal ser1out ; send SYN |
add $17,$0,WAIT_DELAY ; wait for ACK |
handshake2: |
sub $17,$17,1 |
jal ser1inchk |
bne $2,$0,handshake3 |
bne $17,$0,handshake2 |
add $4,$0,timeoutmsg |
jal puts |
bne $16,$0,handshake1 |
add $4,$0,frustratedmsg |
jal puts |
j dskcapx |
handshake3: |
jal ser1in |
add $8,$0,ACK |
bne $2,$8,dskcapx |
; we got an ACK so we return it |
add $4,$0,ACK |
jal ser1out |
|
; ask it for its capacity |
add $4,$0,'c' |
jal ser1out ; request |
jal ser1in ; first byte of response |
bne $2,$0,dskcapx ; exit if error |
|
; all is well and the server will give us the capacity |
add $16,$0,4 ; 4 bytes to read |
dskcap1: |
sll $18,$18,8 |
jal ser1in |
or $18,$18,$2 ; most significant byte first |
sub $16,$16,1 |
bne $16,$0,dskcap1 |
|
; return value is in $18 |
dskcapx: |
add $2,$0,$18 |
ldw $16,$29,0 |
ldw $17,$29,4 |
ldw $18,$29,8 |
ldw $31,$29,12 |
add $29,$29,16 |
jr $31 |
|
.data |
.align 4 |
|
trymsg: |
.byte "Trying to connect to disk server..." |
.byte 0x0A, 0 |
|
timeoutmsg: |
.byte "Request timed out..." |
.byte 0x0A, 0 |
|
frustratedmsg: |
.byte "Unable to establish connection to disk server." |
.byte 0x0A, 0 |
|
.code |
.align 4 |
|
dskioser: |
sub $29,$29,24 |
stw $16,$29,0 |
stw $17,$29,4 |
stw $18,$29,8 |
stw $19,$29,12 |
stw $20,$29,16 |
stw $31,$29,20 |
add $16,$0,$4 ; command |
add $17,$0,$5 ; start at sector |
add $8,$0,0xc0000000 |
or $18,$8,$6 ; memory address (logicalized) |
add $19,$0,$7 ; number of sectors |
|
; switch over command |
add $8,$0,'r' |
beq $8,$16,dskior ; read |
add $8,$0,'w' |
beq $8,$16,dskiow ; write |
; unknown command |
add $2,$0,1 ; value != 0 signifies error |
j dskiox |
|
; read from disk |
dskior: |
dskior1: ; loop over number of sectors |
beq $19,$0,dskiorsuc ; successful return |
sub $19,$19,1 |
; read a sector |
add $4,$0,'r' |
jal ser1out |
; send sector number |
add $20,$0,32 ; 4 bytes |
dskior2: |
sub $20,$20,8 |
slr $4,$17,$20 |
and $4,$4,0xff |
jal ser1out |
bne $20,$0,dskior2 |
add $17,$17,1 |
; get answer |
jal ser1in |
bne $2,$0,dskiox ; $2 != 0 so we use it as return code |
; read data |
add $20,$0,512 |
dskior3: |
sub $20,$20,1 |
jal ser1in |
stb $2,$18,0 |
add $18,$18,1 |
bne $20,$0,dskior3 |
j dskior1 |
dskiorsuc: |
add $2,$0,$0 |
j dskiox |
|
; write to disk |
dskiow: |
dskiow1: ; loop over number of sectors |
beq $19,$0,dskiowsuc ; successful return |
sub $19,$19,1 |
; write a sector |
add $4,$0,'w' |
jal ser1out |
; send sector number |
add $20,$0,32 ; 4 bytes |
dskiow2: |
sub $20,$20,8 |
slr $4,$17,$20 |
and $4,$4,0xff |
jal ser1out |
bne $20,$0,dskiow2 |
add $17,$17,1 |
; write data |
add $20,$0,512 |
dskiow3: |
sub $20,$20,1 |
ldbu $4,$18,0 |
jal ser1out |
add $18,$18,1 |
bne $20,$0,dskiow3 |
; get answer |
jal ser1in |
bne $2,$0,dskiox |
j dskiow1 |
dskiowsuc: |
add $2,$0,$0 |
dskiox: |
ldw $16,$29,0 |
ldw $17,$29,4 |
ldw $18,$29,8 |
ldw $19,$29,12 |
ldw $20,$29,16 |
ldw $31,$29,20 |
add $29,$29,24 |
jr $31 |