Skip to content

Commit 0151c63

Browse files
authored
Merge pull request #2310 from asiekierka/feature/swan-font-4x8
[swan] Add 4x8 font, improve memory usage
2 parents 44e7960 + ccc1427 commit 0151c63

File tree

20 files changed

+572
-144
lines changed

20 files changed

+572
-144
lines changed

Documentation/text/swan.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ELKS on WonderSwan memory layout
2+
3+
+-------------------- seg off linear size (size decimal) --------------------+
4+
| interrupt vectors 0000:0000 00000 0400 (1024)
5+
| kernel setup data 0040:0000 00400 0200 (512) (CONFIG_ROM_SETUP_DATA=0x0040)
6+
| bell wave table 0060:0000 00600 0010 (16)
7+
| kernel near dat/bss 0061:0000 00610 .... (...)
8+
| video area ....:0000 ..... .... (see below)
9+
| kernel near heap 0800:0000 08000 7E00 (32256)
10+
| palette area 0FE0:0000 00200 0200 (512)
11+
| application memory 1000:0000 10000 10000 (64K)
12+
| ...
13+
| start of ROM disk 4000:0000 40000 B0000 (704K, CONFIG_ROMFS_BASE=0x4000)
14+
| kernel code segment F000:0000 F0000 FFF0 (65520)
15+
| ROM footer FFFF:0000 FFFF0 0010 (16)
16+
+--------------------------------------------------------------------------------+
17+
18+
Video area usage
19+
20+
8x8 text mode
21+
font: 0x5000 - 0x5FFF
22+
console 1: 0x4800 - 0x4FFF
23+
console 2: 0x4000 - 0x47FF
24+
...
25+
console 6: 0x2000 - 0x27FF
26+
27+
4x8 text mode
28+
font: 0x6000 - 0x7FFF
29+
console 1: 0x5000 - 0x5FFF
30+
console 2: 0x4000 - 0x4FFF
31+
...
32+
console 4: 0x2000 - 0x2FFF

buildimages.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ build_rom_8088()
6262
mv image/romfs.bin image/romfs-8088.bin
6363
}
6464

65+
# build Swan rom image
66+
build_rom_swan()
67+
{
68+
cleanup
69+
cp swan.config .config
70+
make
71+
mv image/rom.wsc image/rom-swan.wsc
72+
}
73+
6574
# build IBM PC versions
6675
build_ibm()
6776
{
@@ -100,7 +109,8 @@ fi
100109
# full (re)build including C library and all applications
101110
make clean
102111
build_pc98
103-
build_8018x
104-
build_8088
112+
build_rom_8018x
113+
build_rom_8088
114+
build_rom_swan
105115
build_ibm
106116
build_ibm_all

elks/arch/i86/drivers/char/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ endif
6767
else
6868
ifdef CONFIG_ARCH_SWAN
6969
ifdef CONFIG_CONSOLE_DIRECT
70-
OBJS += console-direct-swan.o console-font-8x8-swan.o
70+
OBJS += console-direct-swan.o console-font-4x8-swan.o console-font-8x8-swan.o
7171
endif
7272
else
7373
ifdef CONFIG_CONSOLE_DIRECT
@@ -98,7 +98,7 @@ ifdef CONFIG_ARCH_SWAN
9898
ifdef CONFIG_CONSOLE_HEADLESS
9999
OBJS += console-headless.o
100100
endif
101-
OBJS += kbd-poll.o conio-swan.o
101+
OBJS += kbd-poll.o bell-swan.o conio-swan.o
102102
endif
103103

104104
ifdef CONFIG_ARCH_IBMPC
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* elks/arch/i86/drivers/char/bell-swan.c
3+
*
4+
* This file emulates the PC speaker.
5+
*/
6+
7+
#include <linuxmt/config.h>
8+
#include <linuxmt/memory.h>
9+
#include <arch/ports.h>
10+
#include <arch/io.h>
11+
#include <arch/swan.h>
12+
13+
14+
#define BELL_FREQUENCY 800
15+
#define BELL_PERIOD (1193181/BELL_FREQUENCY)
16+
17+
/*
18+
* Turn PC speaker on at specified frequency (more precisely, wave period).
19+
*/
20+
void soundp(unsigned period)
21+
{
22+
/* FIXME: Only perform this initialization once. */
23+
unsigned int wave_seg = 0x60;
24+
int i;
25+
26+
/* Write square wave pattern */
27+
for (i = 0; i < 8; i++) {
28+
pokeb(i, (seg_t) wave_seg, 0xFF);
29+
pokeb(i + 8, (seg_t) wave_seg, 0x00);
30+
}
31+
32+
/* Configure audio */
33+
outb(wave_seg >> 2, AUD_BASE_PORT);
34+
outw(0x09 << 8, AUD_CONTROL_PORT);
35+
36+
/* Play sample */
37+
outw(period / 12, AUD_CH1_FREQ_PORT);
38+
outb(0xFF, AUD_CH1_VOL_PORT);
39+
outb(0x01, AUD_CONTROL_PORT);
40+
}
41+
42+
/*
43+
* Turn PC speaker off.
44+
*/
45+
void nosound(void)
46+
{
47+
outb(0x01, AUD_CONTROL_PORT);
48+
}
49+
50+
/*
51+
* Actually sound the speaker.
52+
*/
53+
void bell(void)
54+
{
55+
register volatile unsigned int i = 60000U;
56+
57+
soundp(BELL_PERIOD);
58+
while (--i)
59+
continue;
60+
nosound();
61+
}

elks/arch/i86/drivers/char/config.in

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ mainmenu_option next_comment
1111
8018x CONFIG_CONSOLE_8018X \
1212
Headless CONFIG_CONSOLE_HEADLESS" Direct
1313
if [ "$CONFIG_CONSOLE_DIRECT" = "y" ]; then
14+
if [ "$CONFIG_ARCH_SWAN" = "y" ]; then
15+
choice 'Console font' \
16+
"8x8 CONFIG_CONSOLE_FONT_8X8 \
17+
4x8 CONFIG_CONSOLE_FONT_4X8" 4x8
18+
fi
1419
bool ' Scancode keyboard driver' CONFIG_KEYBOARD_SCANCODE y
1520
bool ' Dual-screen console support' CONFIG_CONSOLE_DUAL n
1621
fi
@@ -19,14 +24,14 @@ mainmenu_option next_comment
1924
bool 'Console ANSI terminal emulation' CONFIG_EMUL_ANSI y
2025
fi
2126
if [ "$CONFIG_CONSOLE_DIRECT" = "y" ]; then
22-
source elks/arch/i86/drivers/char/KeyMaps/config.in
27+
source elks/arch/i86/drivers/char/KeyMaps/config.in
2328
fi
2429

2530
comment 'Other character devices'
2631
if [ "$CONFIG_CONSOLE_SERIAL" = "n" ]; then
27-
bool 'Serial device driver' CONFIG_CHAR_DEV_RS y
32+
bool 'Serial device driver' CONFIG_CHAR_DEV_RS y
2833
else
29-
define_bool CONFIG_CHAR_DEV_RS y
34+
define_bool CONFIG_CHAR_DEV_RS y
3035
fi
3136
bool 'Parallel device driver' CONFIG_CHAR_DEV_LP y
3237
#bool 'CGA text mode videobuffer' CONFIG_CHAR_DEV_CGATEXT n

0 commit comments

Comments
 (0)