wok-tiny view linux/stuff/cmdline.S @ rev 109

Update custom-console
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 27 10:51:46 2016 +0100 (2016-02-27)
parents
children 5e2b41f82f13
line source
1 start_of_setup = 0xF00
2 cmd_line_ptr = 0x228
3 default_cmdline = 0x300
4 #define ABS(x) (x)-0x230
5 #ifdef BUGGY
6 #define EDIT_CMDLINE
7 #endif
9 .code16
10 .org 0
11 //.org 0x230
12 tranpoline:
13 call start_of_setup2
14 base = 3
15 rep
16 stosb
17 popw %ds
18 ret
20 start_of_setup2:
21 popw %di // caller nextip = base
22 pushw %di
23 pushw %ds // caller %ds
24 pushw %cs
25 popw %ds
26 xorl %eax, %eax
27 leaw ABS(default_cmdline)-base(%di), %si
28 cmpb %al, (%si)
29 je no_cmdline
30 orl ABS(cmd_line_ptr)-base(%di), %eax
31 jne not_default
32 cld
34 #ifdef EDIT_CMDLINE
35 # The cmdline can be entered and modifed at boot time.
36 # Only characters before the cursor are passed to the kernel.
38 movw %ax, %es
39 movw %si, %dx
40 movb $13, %al
41 puts:
42 #ifdef BUGGY
43 call putc
44 #endif
45 lodsb
46 orb %al, %al
47 jnz puts
48 endputs:
49 cmdlp:
50 movb $0x20, %al # clear end of line
51 cmdlpz:
52 call putc # with Space
53 subb $0x18, %al # and BackSpace
54 jnc cmdlpz
55 decw %si
56 cmdget:
57 clock = 0x46C
58 movw $clock, %bx
59 #define DELAY 5
60 movb $257-(DELAY*182)/10, %es:(%bx)
61 waitkbd:
62 movw $0x10D, %ax # test keyboard, timeout => CR
63 cmpb %es:(%bx),%ah
64 je waitdone
65 int $0x16
66 jz waitkbd
67 cbw
68 int $0x16 # eat char
69 movw %bx, %es # disable timeout
70 waitdone:
71 cmpb $8, %al # BackSpace ?
72 je cmdbs
73 movb %al, (%si) # store char
74 lodsw # %si += 2
75 cmdbs:
76 cmpw %dx, %si
77 je cmdget
78 call putc
79 cmpb $10, %al # Enter/linefeed ?
80 jne cmdlp
81 movb %bh,-2(%si) # set end of string and remove CR
82 endcmdline:
83 movw %dx, %si
84 #endif
86 xorw %cx, %cx
87 len:
88 lodsb
89 orb %al, %al
90 loopne len
91 addw %cx, %si
92 cbw
93 cdq
94 andb $0xFE, %cl
95 popw %bp // caller %ds
96 addw %cx, %sp
97 pushw %di // caller nextip
98 pushw %bp // caller %ds
99 pushw %ss
100 popw %es
101 movw %sp, %ax
102 movw %es, %dx
103 shll $4, %edx
104 addl %eax, %edx
105 movl %edx, ABS(cmd_line_ptr)-base(%di)
106 pushw %di
107 xchgw %ax, %di
108 negw %cx
109 rep
110 movsb
111 popw %di
112 not_default:
113 no_cmdline:
114 pushw %cs
115 popw %es
116 movw $ABS(start_of_setup)-base, %cx
117 leaw ABS(start_of_setup)-base(%di), %ax
118 pushw %ax
119 xorw %ax, %ax
120 jmp *%di
122 #ifdef EDIT_CMDLINE
123 putlf:
124 xorb $10^13, %al
125 putc:
126 movb $0xe, %ah
127 movw $7, %bx
128 int $0x10
129 cmpb $13, %al
130 je putlf
131 ret
132 #endif