00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00091 #include <sys/ports.h>
00092
00093 static void put_addr(unsigned short value);
00094 static void put_char(unsigned char c);
00095
00096 static inline void
00097 reboot()
00098 {
00099 #ifndef NO_REBOOT
00100
00101
00102 typedef void __attribute__ ((noreturn)) (* func)();
00103
00104 func handler;
00105
00106 set_bus_single_chip ();
00107
00108
00109 handler = *((func*) 0xbffe);
00110 handler ();
00111 #endif
00112 }
00113
00114 void
00115 _start()
00116 {
00117 unsigned char c;
00118 volatile unsigned char* addr;
00119 unsigned char nok = 1;
00120
00121 set_bus_expanded ();
00122
00123
00124
00125 addr = (volatile unsigned char*) 0x0ff;
00126 while (1)
00127 {
00128 addr++;
00129
00130
00131
00132
00133
00134 if (addr == (unsigned char*) 0)
00135 {
00136 for (c = 5; --c != 0; )
00137 put_char ('\n');
00138
00139 reboot ();
00140
00141
00142
00143 addr += 0xff;
00144 continue;
00145 }
00146
00147
00148 if (addr == _io_ports)
00149 {
00150 addr += M6811_IO_SIZE;
00151 continue;
00152 }
00153
00154
00155
00156 c = ~*addr;
00157 *addr = c;
00158 if (c != *addr)
00159 {
00160 if (nok)
00161 continue;
00162
00163
00164 nok = 1;
00165 put_char ('-');
00166 put_addr ((unsigned short) addr);
00167 }
00168 else
00169 {
00170 if (nok == 0)
00171 continue;
00172
00173
00174 nok = 0;
00175 put_char ('+');
00176 put_addr ((unsigned short) addr);
00177 }
00178 }
00179 }
00180
00181
00182
00183 static void
00184 put_hex(unsigned short value)
00185 {
00186 put_char ("0123456789ABCDEF"[(value >> 4) & 0x0F]);
00187 put_char ("0123456789ABCDEF"[value & 0x0F]);
00188 }
00189
00190
00191
00192 static void
00193 put_addr(unsigned short value)
00194 {
00195 put_hex (value >> 8);
00196 put_hex (value);
00197 put_char ('\n');
00198 }
00199
00200
00201
00202 static void
00203 put_char(unsigned char c)
00204 {
00205 while (!(_io_ports[M6811_SCSR] & M6811_TDRE))
00206 continue;
00207
00208 _io_ports[M6811_SCDR] = c;
00209 _io_ports[M6811_SCCR2] |= M6811_TE;
00210 }