2 #define RET_LABEL(label) \
5 #define CALL_LABEL(label) \
18 #include "console.inc"
20 #include "ramtest.inc"
24 // (c) 2004 Bryan Chafy, This program is released under the GPL
26 // LLShell, A low level interactive debug shell
27 // Designed to be an interactive shell that operates with zero
28 // system resources. For example at initial boot.
30 // to use, jump to label "low_level_shell"
31 // set %esp to the return address for exiting
34 #define UART_BASEADDR $0x3f8
35 #define resultreg %esi
36 #define subroutinereg %edi
37 #define freqtime $2193 // 1.93 * freq
38 #define timertime $6000
45 .string "\r\n! Low Level Shell (LLShell) (c)2004 Bryan Chafy \r\n\r\n"
49 .string "bad command\r\n"
51 .string "sorry, not yet implemented\r\n"
53 .string "\r\nList of commands:\r\n \
54 \r\nbeep -- pc speaker beep \
55 \r\nrst (or RST) -- reset \
56 \r\nout(b,w,l) <val> <port> -- raw out val at port \
57 \r\nin(b,w,l) <port> -- show raw port value \
58 \r\njmp <address> -- jmp to address (llshell addr is in eax) \
59 \r\ncall <address> -- funcion call (assumes a working stack) \
60 \r\ncli -- clear interrupts \
61 \r\nsti -- enable interrupts \
62 \r\npush <value> -- push value onto stack \
63 \r\npop -- pop from stack and display \
64 \r\nwm(b,w,l) <addr> <val> -- write mem \
65 \r\ndm <addr> <lines> -- dump mem \
66 \r\nmcp <src> <dst> <size> -- mem copy \
67 \r\nmpat <pat> <dst> <size> -- mem pattern \
68 \r\nmemt <begin> <end> -- memory test \
69 \r\npcir(b,w,l) <loc> -- pci read config \
70 \r\npciw(b,w,l) <loc> <val> -- pci write config \
71 \r\ndl <addr> <size> -- memory download (display xor cheksum at completion) \
72 \r\ncram <addr> <size> -- enable cache to be ram (experimental) \
73 \r\nbaud <val> -- change baudrate (not yet implemented) \
74 \r\nexit -- exit shell \
75 \r\nAll values in hex (0x prefixing ok) \
84 //ASSUME CS:@CODE, DS:@DATA
92 mov $preamble,subroutinereg
95 mov $welcome,resultreg
96 mov $readcommand,subroutinereg
100 mov $prompt,resultreg
101 mov $rcmd,subroutinereg
105 mov $readcommand,subroutinereg
109 mov UART_BASEADDR+5,%dx
114 mov UART_BASEADDR,%dx
115 in %dx,%al //char in al
119 mov UART_BASEADDR+5,%dx
124 mov UART_BASEADDR,%dx
126 out %al,%dx // output char
134 cmp $0x20,%al //space
200 jz dodl // download to mem <loc> <size>
202 jz jmpto // jump to location (eax holds return addr)
204 jz baud // change baudrate
206 jz doint // trigger an interrupt
208 jz callto // call assumes memory
210 jz dopush // assumes mem
212 jz dopop // assumes mem
214 jz cram // cache ram trick <location> <size>
216 jz mcp // mem copy <src> <dst> <size>
225 mov $badcmd,resultreg
226 mov $readcommand,subroutinereg
233 mov UART_BASEADDR+5,%dx
238 mov UART_BASEADDR,%dx
243 mov UART_BASEADDR+5,%dx
248 mov UART_BASEADDR,%dx
250 out %al,%dx // output char
260 cmp $0x20,%al //space
294 // ebx,ecx,ebp,esp(?)
298 mov $ramtest,resultreg
299 mov $test1a,subroutinereg
302 mov $welcome,resultreg
303 mov $readcommand,subroutinereg
308 movl $dmem1a, subroutinereg
311 mov resultreg,%ebx // address
312 movl $dmem1b, subroutinereg
315 mov resultreg,%ecx // length
319 mov $daddr1,subroutinereg
322 mov $spaces,resultreg
323 mov $startshowm,subroutinereg
328 mov $showm1,subroutinereg
333 mov $showm2,subroutinereg
338 mov $showm3,subroutinereg
343 mov $showa0,subroutinereg
349 mov $showa1,subroutinereg
350 jmp displayasciilinear
354 mov $showa2,subroutinereg
355 jmp displayasciilinear
359 mov $showa3,subroutinereg
360 jmp displayasciilinear
364 mov $doneshow,subroutinereg
365 jmp displayasciilinear
368 mov $doneshow1,subroutinereg
381 movl $outb1a, subroutinereg
385 movl $outb1b, subroutinereg
395 movl $outw1a, subroutinereg
399 movl $outw1b, subroutinereg
409 movl $outd1a, subroutinereg
413 movl $outd1b, subroutinereg
422 movl $wmemba, subroutinereg
426 movl $wmembb, subroutinereg
434 movl $wmemwa, subroutinereg
438 movl $wmemwb, subroutinereg
446 movl $wmemla, subroutinereg
450 movl $wmemlb, subroutinereg
459 movl $inb1a, subroutinereg
466 mov $readcommand,subroutinereg
471 movl $inw1a, subroutinereg
478 mov $readcommand,subroutinereg
483 movl $ind1a, subroutinereg
489 mov $readcommand,subroutinereg
493 movl $jmp1a, subroutinereg
496 mov $readcommand,%eax
500 movl $call1a, subroutinereg
503 mov $readcommand,%eax
508 movl $push1a, subroutinereg
516 movl $int1a, subroutinereg
520 // need to lookup int table?
529 movl $readcommand, subroutinereg
543 // resultreg= pointer to string terminated by \0
548 mov UART_BASEADDR+5,%dx
553 mov UART_BASEADDR,%dx
555 out %al,%dx // output char
585 mov UART_BASEADDR+5,%dx
590 mov UART_BASEADDR,%dx
592 out %al,%dx // output char
624 mov UART_BASEADDR+5,%dx
629 mov UART_BASEADDR,%dx
631 out %al,%dx // output char
687 mov $readcommand,subroutinereg
691 movl $memt1, subroutinereg
695 movl $memt2, subroutinereg
700 mov $readcommand,%esp // internal to linux bios
704 movl $pcirb1, subroutinereg
711 mov $readcommand,subroutinereg
715 movl $pcirw1, subroutinereg
722 mov $readcommand,subroutinereg
726 movl $pcirl1, subroutinereg
730 PCI_READ_CONFIG_DWORD
732 mov $readcommand,subroutinereg
739 movl $pciwb1, subroutinereg
743 movl $pciwb2, subroutinereg
748 PCI_WRITE_CONFIG_BYTE
752 movl $pciww1, subroutinereg
756 movl $pciww2, subroutinereg
761 PCI_WRITE_CONFIG_WORD
765 movl $pciwl1, subroutinereg
769 movl $pciwl2, subroutinereg
774 PCI_WRITE_CONFIG_DWORD
778 //likely not working. Just testing for now
779 movl $cram1, subroutinereg
783 movl $cram1, subroutinereg
789 and $0x9fffffff,%eax // also try 0x0fff, 0x2ff(write back)...
803 movl $dl1, subroutinereg
807 movl $dl2, subroutinereg
811 mov resultreg,subroutinereg
814 mov UART_BASEADDR+5,%dx
819 mov UART_BASEADDR,%dx
825 mov subroutinereg,%ecx
835 mov $readcommand,subroutinereg
841 mov $readcommand,subroutinereg
845 movl $mcp1, subroutinereg
849 movl $mcp2, subroutinereg
853 movl $mcp3, subroutinereg
867 movl $pat1, subroutinereg
871 movl $pat2, subroutinereg
875 movl $pat3, subroutinereg
890 RETSP // if there's no stack yet, caller must set %esp manually
891 // RET_LABEL(low_level_shell)
896 movl $sys_IOPL, %eax # system-call ID-number
897 movl $3, %ebx # new value for IO0PL
898 int $0x80 # enter the kernel