Browse Source

* Added assembly code for inb() and outb().

* Print a small message at kernel boot time just to check that the kernel
    was properly loaded.
tags/v0.99.beta14
Sam Hocevar sam 19 years ago
parent
commit
c063b0a54d
5 changed files with 50 additions and 11 deletions
  1. +15
    -7
      build-kernel
  2. +3
    -1
      caca/caca_internals.h
  3. +3
    -1
      cucul/cucul_internals.h
  4. +10
    -0
      kernel/kernel.c
  5. +19
    -2
      kernel/kernel.h

+ 15
- 7
build-kernel View File

@@ -1,7 +1,7 @@
#! /bin/sh

## Kernel-mode libcaca compilation script -- Sam Hocevar <sam@zoy.org>
## $Id: build-dos 333 2006-03-07 12:39:34Z sam $
## $Id$

set -x
set -e
@@ -15,16 +15,24 @@ LDFLAGS="-nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
--enable-vga --disable-imlib2 --disable-doc \
--host i386

(cd cucul && make)
(cd caca && make)
# We need this.
make clean

(cd src && make cacafire-aafire.o)
cd cucul && make && cd ..
cd caca && make && cd ..

(cd kernel &&
gcc $CFLAGS -c multiboot.S -o multiboot.o
gcc $CFLAGS $CPPFLAGS -c kernel.c -o kernel.o)
cd src && make cacafire-aafire.o && cd ..

cd kernel &&
gcc $CFLAGS -c multiboot.S -o multiboot.o &&
gcc $CFLAGS $CPPFLAGS -c kernel.c -o kernel.o &&
cd ..

gcc $LDFLAGS -o src/cacafire kernel/multiboot.o kernel/kernel.o src/cacafire-aafire.o caca/.libs/libcaca.a cucul/.libs/libcucul.a

objcopy -O binary src/cacafire cacafire.boot

# For further development: create floppy images using the kernel
#gcc -traditional -c -o bootsect.o bootsect.S
#ld -Ttext 0x0 -s --oformat binary bootsect.o -o cacafire.img


+ 3
- 1
caca/caca_internals.h View File

@@ -26,7 +26,9 @@
# define CUSTOM_INTTYPES
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint32_t;
typedef long int intptr_t;
typedef long unsigned int uintptr_t;
#endif

#if !defined(_DOXYGEN_SKIP_ME)


+ 3
- 1
cucul/cucul_internals.h View File

@@ -26,7 +26,9 @@
# define CUSTOM_INTTYPES
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint32_t;
typedef long int intptr_t;
typedef long unsigned int uintptr_t;
#endif

struct cucul_context


+ 10
- 0
kernel/kernel.c View File

@@ -29,8 +29,18 @@ static uint32_t *freemem = (uint32_t*) 0x00200000;
/* Multiboot kernel entry point */
void cmain(unsigned long int magic, unsigned long int addr)
{
static char const text[] = "Booting libcaca kernel...";
char const *ptr = text;
char *video = (char*)0xB8000;

char *argv[] = { NULL };
int argc = 0;

/* Print a text message to say hello */
while(*ptr)
*video = *ptr++; video += 2;

/* Launch the main program */
main(argc, argv);
}



+ 19
- 2
kernel/kernel.h View File

@@ -27,12 +27,29 @@
#define __BYTE_ORDER 1
#define __BIG_ENDIAN 2

/* Assembly code for outb and inb */
extern inline void outb(unsigned char val, unsigned short port);
extern inline unsigned char inb(unsigned short port);

extern inline void outb(unsigned char val, unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1" : : "a" (val), "Nd" (port));
}

extern inline unsigned char inb(unsigned short port)
{
unsigned char tmp;
__asm__ __volatile__ ("inb %w1,%0" : "=a" (tmp) : "Nd" (port));
return tmp;
}

/* Various typedefs -- some are x86-specific */
#define CUSTOM_INTTYPES
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned int uintptr_t;
typedef unsigned long int uint32_t;
typedef long int intptr_t;
typedef long unsigned int uintptr_t;

typedef unsigned int size_t;



Loading…
Cancel
Save