130 likes | 264 Views
Memory. The programmer’s model .text, .data user program (instruction memory) and data area .ktext, .kdata kernel program and data area The computer’s model instruction memory user space 0-7fffffff, kernel space 80000000 - ffffffff data memory
E N D
Memory The programmer’s model • .text, .data • user program (instruction memory) and data area • .ktext, .kdata • kernel program and data area The computer’s model • instruction memory • user space 0-7fffffff, kernel space 80000000 - ffffffff • data memory • user space 0-7fffffff, kernel space 80000000 - ffffffff
How can we tell User/Kernel apart? 31 30 29 28 27 0 ? x x x x…... By looking at the address! • PC[31] • 0, User program • 1, Kernel program • data addr[31] • 0, User data • 1, Kernel data
Address Decoding So far; Instruction decoding • Now address decoding 32 PC PC[31] TAP BOX [31]
CPU model How to detect a kernel instruction kinst CP0 MIPS PIPELINE 32 instruction address [31] Instruction Memory
CPU model How to detect kernel data access kdata CP0 MIPS PIPELINE data mem address 32 [31] Instruction Memory
Address Mapping CP0 MIPS PIPELINE 32 32 data mem address data 8/16/32 bits Address bus Data bus
Address Mapping CP0 MIPS PIPELINE Control signals r/w, 8, 16, 32 bits Address bus Data bus Control bus
Address Mapping Address bus Data bus Control bus 00……0 .. .. . . 0fff…..f 10……0 .. .. . . 1fff…..f n0……0 .. .. . . nfff…..f …. Mem 1 Mem 2 Mem n
Enable and REDUCED address • Address 0-7fffffff 31 30 29 28 27 0 0 0 0 0 [27:0] points out the REDUCED address in mem 1 mem 1 Enable
lw $t0 0($t1), $t1=0…0 Address bus Data bus Control bus read=(ADDR[31..28]=0000) and CTRL[READ] word=CTRL[WORD] 32 address decoder read, word 28 data word 00……0 .. . 0fff…..f
lw $t0 0($t1), $t1=0…0 Address bus Data bus Control bus CTRL[stall]=0 Until data ready 32 address decoder read, word 28 data word 00……0 .. . 0fff…..f
sb $t0 0($t1), $t1=0…0 Address bus Data bus Control bus write=(ADDR[31..28]=0000) and CTRL[WRITE] byte=CTRL[BYTE] 32 address decoder write, byte 28 data word 00……0 .. . 0fff…..f
sw $t0 0($t1), $t1=0…1 Address bus Data bus Control bus CTRL[ALIGNMENT]=(ADDR[31..28]=0000) and (ADDR[0] or ADDR[1]) 32 address decoder Alignment Error!!!