Skip to content

Commit 73fce59

Browse files
author
Sebastien Bourdeauducq
committedFeb 7, 2012
software: shell from original BIOS
1 parent ef0667d commit 73fce59

File tree

8 files changed

+474
-33
lines changed

8 files changed

+474
-33
lines changed
 

‎software/bios/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ bios.elf: linker.ld $(OBJECTS) libs
1818
bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs
1919

2020
%.elf:
21-
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) -L$(M2DIR)/software/libbase -lbase
21+
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) -L$(M2DIR)/software/libbase -L$(M2DIR)/software/libextra -lbase -lextra
2222
chmod -x $@
2323

2424
libs:
2525
make -C $(M2DIR)/software/libbase
26+
make -C $(M2DIR)/software/libextra
2627

2728
.PHONY: clean libs
2829

‎software/bios/main.c

+444-9
Large diffs are not rendered by default.

‎software/include/base/console.h

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn);
2828
char readchar(void);
2929
int readchar_nonblock(void);
3030

31-
int puts(const char *s);
3231
void putsnonl(const char *s);
3332

3433
#endif /* __CONSOLE_H */

‎software/include/base/stdio.h

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
#include <stdlib.h>
2222

23+
int putchar(int c);
24+
int puts(const char *s);
25+
2326
int snprintf(char *buf, size_t size, const char *fmt, ...);
2427
int scnprintf(char *buf, size_t size, const char *fmt, ...);
2528
int sprintf(char *buf, const char *fmt, ...);

‎software/libbase/console.c

+5-20
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include <console.h>
2020
#include <stdio.h>
2121
#include <stdarg.h>
22-
#include <irq.h>
23-
#include <hw/interrupts.h>
2422

2523
static console_write_hook write_hook;
2624
static console_read_hook read_hook;
@@ -37,11 +35,12 @@ void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn)
3735
read_nonblock_hook = rn;
3836
}
3937

40-
static void writechar(char c)
38+
int putchar(int c)
4139
{
4240
uart_write(c);
4341
if(write_hook != NULL)
4442
write_hook(c);
43+
return c;
4544
}
4645

4746
char readchar(void)
@@ -62,34 +61,20 @@ int readchar_nonblock(void)
6261

6362
int puts(const char *s)
6463
{
65-
unsigned int oldmask;
66-
67-
oldmask = irq_getmask();
68-
irq_setmask(IRQ_UART); // HACK: prevent UART data loss
69-
7064
while(*s) {
71-
writechar(*s);
65+
putchar(*s);
7266
s++;
7367
}
74-
writechar('\n');
75-
76-
irq_setmask(oldmask);
68+
putchar('\n');
7769
return 1;
7870
}
7971

8072
void putsnonl(const char *s)
8173
{
82-
unsigned int oldmask;
83-
84-
oldmask = irq_getmask();
85-
irq_setmask(IRQ_UART); // HACK: prevent UART data loss
86-
8774
while(*s) {
88-
writechar(*s);
75+
putchar(*s);
8976
s++;
9077
}
91-
92-
irq_setmask(oldmask);
9378
}
9479

9580
int printf(const char *fmt, ...)

‎software/libextra/Makefile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
M2DIR=../..
2+
include $(M2DIR)/software/include.mak
3+
4+
OBJECTS=crc16.o crc32.o
5+
6+
all: libextra.a
7+
8+
# pull in dependency info for *existing* .o files
9+
-include $(OBJECTS:.o=.d)
10+
11+
libextra.a: $(OBJECTS)
12+
$(AR) clr libextra.a $(OBJECTS)
13+
$(RANLIB) libextra.a
14+
15+
.PHONY: clean
16+
17+
clean:
18+
rm -f $(OBJECTS) $(OBJECTS:.o=.d) libextra.a .*~ *~

‎software/libextra/crc16.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <crc.h>
1+
#include <extra/crc.h>
22

33
static const unsigned int crc16_table[256] = {
44
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,

‎software/libextra/crc32.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* For conditions of distribution and use, see copyright notice in zlib.h
44
*/
55

6-
#include <crc.h>
6+
#include <extra/crc.h>
77

88
static const unsigned int crc_table[256] = {
99
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,

0 commit comments

Comments
 (0)
Please sign in to comment.