Skip to content

Commit 53eb29e

Browse files
committed
amiga + c64
1 parent 0f492b8 commit 53eb29e

File tree

11 files changed

+409
-335
lines changed

11 files changed

+409
-335
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,12 @@ OBJCOPY := $(shell command which objcopy)$(EXT)
171171
#.PHONY: confirm
172172
all: confirm clean setup dosshell $(BIN_DIR)/bootcd.iso
173173
setup:
174-
@( $(MKDIR) -p $(BUI_DIR) $(BUI_DIR)/bin $(BUI_DIR)/bin/content $(BUI_DIR)/hex ;\
174+
@( $(MKDIR) -p $(BUI_DIR) ;\
175+
$(MKDIR) -p $(BUI_DIR)/hex ;\
176+
$(MKDIR) -p $(BUI_DIR)/bin ;\
177+
$(MKDIR) -p $(BUI_DIR)/bin/content ;\
175178
$(MKDIR) -p $(BIN_DIR)/content/img ;\
176-
$(MKDIR) -p $(BIN_DIR)/content/img/shell ;\
179+
$(MKDIR) -p $(BIN_DIR)/content/shell ;\
177180
$(MKDIR) -p $(BUI_DIR)/obj ;\
178181
$(MKDIR) -p $(BUI_DIR)/obj/pe ;\
179182
$(MKDIR) -p $(OBJ_DIR)/user32/TurboVision/platform ;\

build/bin/kernel.map

Lines changed: 296 additions & 294 deletions
Large diffs are not rendered by default.

build/dep/coff/util.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
T:/a/WelcomeBackOS/build/obj/user32/TurboVision/util.s: \
2-
T:/a/WelcomeBackOS/src/user32/TurboVision/src/util.cc \
1+
T:/a/WelcomeBackOS/build/obj/coff/util.s: \
2+
T:/a/WelcomeBackOS/src/kernel/util.c \
3+
T:/a/WelcomeBackOS/src/kernel/include/proto.h \
34
T:/a/WelcomeBackOS/src/kernel/include/stdint.h
5+
T:/a/WelcomeBackOS/src/kernel/include/proto.h:
46
T:/a/WelcomeBackOS/src/kernel/include/stdint.h:

src/images/amigawb.bmp

153 KB
Binary file not shown.

src/kernel/ahci.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ typedef struct {
109109
uint32_t abar; // physische Adresse der HBA-MMIO-Struktur
110110
} ahci_controller_t;
111111

112+
extern void fillRect16_fast(int x, int y, int w, int h, uint16_t color565);
113+
static inline uint16_t rgb565(uint8_t r, uint8_t g, uint8_t b) {
114+
return (uint16_t)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3));
115+
}
116+
112117
// statische Puffer (aligned nötig)
113118
static uint8_t g_clb[1024] __attribute__((aligned(1024)));
114119
static uint8_t g_fis[256] __attribute__((aligned(256)));
@@ -469,7 +474,7 @@ int check_ahci(void)
469474
#endif
470475
return -1;
471476
}
472-
477+
/*
473478
#if (ISOGUI == 0)
474479
#if (ISOLANG == LANG_ENU)
475480
printformat("First Byte of LBA 0: 0x%x\n", buf[0]);
@@ -483,5 +488,6 @@ int check_ahci(void)
483488
gfx_printf("Erstes Byte von LBA 0: 0x%x\n", buf[0]);
484489
#endif
485490
#endif
491+
*/
486492
return 0;
487493
}

src/kernel/bitmap.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#define BI_RGB 0
1111
#define BI_BITFIELDS 3
1212

13-
extern uint32_t file_read (FILE* f, void* buf, uint32_t len);
14-
extern int file_seek (FILE* f, uint32_t new_pos);
15-
extern void file_close(FILE* f);
13+
extern uint32_t file_read (FILE* f, void* buf, uint32_t len);
14+
extern int file_seek (FILE* f, uint32_t new_pos);
15+
extern void file_close(FILE* f);
1616

1717
# define BI_RGB 0
1818
# define BI_BITFIELDS 3
@@ -41,12 +41,25 @@ typedef struct __attribute__((packed)) {
4141
uint32_t biClrImportant;
4242
} BMP_INFOHDR;
4343

44+
typedef struct __attribute__((packed)) {
45+
uint8_t b, g, r, a; // BMP Palette: B,G,R,0
46+
} RGBQUAD;
47+
4448
typedef struct {
4549
int w, h;
4650
uint32_t pitch; // bytes per row
4751
uint16_t* pixels; // RGB565
4852
} sprite565_t;
4953

54+
typedef unsigned int addr_t; // 32-bit
55+
56+
static inline uint16_t bgr_to_565(uint8_t b, uint8_t g, uint8_t r) {
57+
return (uint16_t)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3));
58+
}
59+
static inline uint16_t rgb565(uint8_t r, uint8_t g, uint8_t b) {
60+
return (uint16_t)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3));
61+
}
62+
5063
static bool read_exact(FILE* f, void* buf, uint32_t len) {
5164
uint32_t got = file_read(f, buf, len);
5265
return got == len;

src/kernel/boot/boot2.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
; ES:DI muss auf einen 256-Byte ModeInfoBlock zeigen.
1111

1212
VBE_MODE_640x400x256 equ 0x4100 ; 256 color
13-
VBE_MODE_640x480x256 equ 0x4111 ; 65k color
13+
VBE_MODE_800x600 equ 0x4114
1414
VBE_LFB_BIT equ 0x4000
1515

1616
MODEINFO_SIZE equ 256
@@ -689,7 +689,7 @@ amiga_start:
689689
; 1) Mode-Info holen
690690
sti
691691
mov ax, 0x4F01 ; VBE-Funktion: Get Mode Info
692-
mov cx, VBE_MODE_640x480x256 ; gewünschter Modus: 0x0100
692+
mov cx, VBE_MODE_800x600
693693
xor bx, bx
694694
mov es, bx
695695
mov di, 0x2000 ; ES -> 0x2000 -> ES:DI = 0000:2000 (phys 0x00002000)
@@ -699,7 +699,7 @@ amiga_start:
699699
jne a__fail
700700

701701
mov ax, 0x4F02
702-
mov bx, VBE_MODE_640x480x256
702+
mov bx, VBE_MODE_800x600
703703
int 0x10
704704
705705
cmp ax, 0x004F

src/kernel/ckernel.cc

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static inline uint16_t rgb565(uint8_t r, uint8_t g, uint8_t b) {
226226

227227
typedef unsigned int addr_t; // 32-bit
228228

229-
static inline void fillSpan16(volatile uint16_t *dst, int count, uint16_t color)
229+
void fillSpan16(volatile uint16_t *dst, int count, uint16_t color)
230230
{
231231
__asm__ __volatile__ (
232232
"cld\n\t"
@@ -257,13 +257,41 @@ void fillRect16_fast(int x, int y, int w, int h, uint16_t color565)
257257
row8 += lfb_pitch; // pitch ist BYTES!
258258
}
259259
}
260+
261+
typedef struct {
262+
int w, h;
263+
uint32_t pitch; // bytes per row
264+
uint16_t* pixels; // RGB565
265+
} sprite565_t2;
266+
267+
void check_iso_mount()
268+
{
269+
if (check_atapi() == 0) {
270+
// ATAPI (IDE) gefunden
271+
printformat("ATAPI: OK.\n");
272+
fillRect16_fast(100,10,130,130,rgb565(250,255,0));
273+
} else {
274+
printformat("ATAPI: NOK\n");
275+
check_ahci();
276+
}
277+
/*
278+
if (iso_mount() != 0) {
279+
//printformat("ISO mount Error.\n");
280+
281+
} else {
282+
283+
//printformat("ISO mount successfully.\n");
284+
}*/
285+
}
260286
extern "C" int ami_main()
261287
{
288+
graph_mode = 4;
289+
262290
idt_init();
263291

264292
paging_init();
265293
kheap_init();
266-
294+
267295
//detect_memory(); // setzt max_mem
268296

269297
uint32_t stack_top = kernel_stack_top;
@@ -272,42 +300,42 @@ extern "C" int ami_main()
272300
uint32_t reserved = ((uint32_t)&__end + 0xFFF) & ~0xFFF;
273301
if (reserved < kernel_stack_top) reserved = kernel_stack_top; // Stack schützen
274302
page_init(reserved);
275-
303+
276304
// 3) aktuellen Stack als esp0 für TSS verwenden
277305
uint32_t esp;
278-
__asm__ volatile("mov %%esp, %0" : "=r"(esp));
306+
//__asm__ volatile("mov %%esp, %0" : "=r"(esp));
279307
gdt_init();
280-
281308
isr_init();
282309
irq_init();
283-
310+
284311
syscall_init();
285312
tasking_init();
286313

287-
const vbe_info_t* mi = ((const vbe_info_t*)0x00002000);
288-
289-
lfb_base = mi->phys_base;
290-
lfb_pitch = mi->pitch;
291-
lfb_bpp = mi->bpp ;
292-
293-
lfb_xres = mi->xres;
294-
lfb_yres = mi->yres;
314+
// ------------------------------
315+
// vesa 0x114: 800 x 600 x 16bpp
316+
// ------------------------------
317+
gfx_init();
295318

296-
size_t fb_bytes = (size_t)lfb_pitch * (size_t)lfb_yres;
297-
298-
// WICHTIG: phys -> virt mappen
299-
uintptr_t lfb_virt = (uintptr_t)mmio_map(lfb_base, (uint32_t)fb_bytes);
300-
301-
// Ab jetzt IMMER die virtuelle Adresse zum Schreiben benutzen!
302-
lfb_base = (uint32_t)lfb_virt;
319+
// ------------------------------
320+
// global c++ constructor's init.
321+
// ------------------------------
322+
call_global_ctors();
323+
check_iso_mount();
303324

325+
__asm__ volatile("sti");
326+
enter_usermode();
304327

305-
fillRect16_fast(0,0,lfb_xres,lfb_yres,rgb565(255,255,255));
306-
for (;;);
328+
// Hierher kommt man normalerweise nicht mehr zurück
329+
for (;;) {
330+
asm volatile("hlt");
331+
}
332+
return 0;
307333
}
334+
308335
// c64 kernel
309336
extern "C" int c64_main()
310337
{
338+
graph_mode = 3;
311339
idt_init();
312340

313341
paging_init();
@@ -401,6 +429,8 @@ extern "C" int txt_main()
401429

402430
settextcolor(14,0);
403431

432+
check_iso_mount();
433+
/*
404434
if (check_atapi() == 0) {
405435
// ATAPI (IDE) gefunden
406436
printformat("ATAPI: OK.\n");
@@ -413,7 +443,7 @@ extern "C" int txt_main()
413443
printformat("ISO mount Error.\n");
414444
} else {
415445
printformat("ISO mount successfully.\n");
416-
}
446+
}*/
417447

418448
__asm__ volatile("sti");
419449

@@ -492,6 +522,8 @@ extern "C" int vid_main()
492522

493523
settextcolor(14,0);
494524

525+
check_iso_mount();
526+
/*
495527
if (check_atapi() == 0) {
496528
// ATAPI (IDE) gefunden
497529
gfx_printf("ATAPI: OK.\n");
@@ -504,7 +536,7 @@ extern "C" int vid_main()
504536
gfx_printf("ISO mount Error.\n");
505537
} else {
506538
gfx_printf("ISO mount successfully.\n");
507-
}
539+
}*/
508540

509541
__asm__ volatile("sti");
510542

src/kernel/fs/iso9660/iso9660.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ int iso_init(iso_read_sectors_t reader)
112112

113113
extern "C" int iso_mount(void)
114114
{
115-
if (!iso_read_sectors)
116-
return -1;
115+
if (!iso_read_sectors) {
116+
return -1;
117+
}
117118

118119
// PVD liegt bei LBA 16
119120
uint8_t* buf = (uint8_t*)kmalloc(2048);

src/kernel/lba.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
; DONT CHANGE THIS FILE - all modifieds will be lost.
33
; -----------------------------------------------------
44
TEST_LBA equ 0
5-
BOOT2_LBA equ 587 ; start LBA BOOT2
5+
BOOT2_LBA equ 664 ; start LBA BOOT2
66
BOOT2_SECTORS equ 2 ; 2048 * 2
77
; -----------------------------------------------------
8-
KERNEL_LBA equ 552 ; start LBA KERNEL
8+
KERNEL_LBA equ 629 ; start LBA KERNEL
99
KERNEL_SECTORS equ 31 ; 2048 * 31
1010
; -----------------------------------------------------
1111
VBE_INFO_ADDR equ 0x0A00

0 commit comments

Comments
 (0)