Multiple SSource File Troubles
Posted: Wed Jan 07, 2004 11:36 pm
I need some help... My OS does not seem to like accessing the functions from a different module. I have tried compiling using both JLOC and LD but to no success Below is my source code, and the LD/JLOC linking scripts. I have been compiling using 'gcc -ffreestanding -c *.c'. I know both functions work because i moved the clear_screen code into the main block and the OS still loaded, but separate them again and the CPU resets.
If anyone is wondering, I got the JLOC script from Johns JLOC/BOOTF/ETC site (the bootf02.zip download)
Any Ideas?
Thanks, Scott
--------------------------------------------------
kernel.c:
Code:
#include "video.h"
char message[]="Welcome to ExOS!";
void init()
{
char *source = message;
char *destination = (char *)0xB8000;
clear_screen();
while (*source) {
*destination++ = *source++;
*destination++ = 0xCE;
}
};
--------------------------------------------------
video.h:
Code:
// Header file for text
// does display functions
// text.h
#if defined( video_h )
//already include
#else
#define video_h
void clear_screen();
#endif
--------------------------------------------------
video.c:
Code:
#include "video.h"
void clear_screen() // clear the entire text screen
{
char *vidmem = (char *)0xB8000;
const long size = 80*25;
long loop;
for (loop=0; loop<size; loop++)
{
*vidmem = ' ';
vidmem++;
*vidmem = 0x07;
vidmem++;
}
}
--------------------------------------------------
LD Linking Script:
Code:
OUTPUT_FORMAT("binary")
ENTRY(_init)
SECTIONS
{
.text 0xFF800000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
--------------------------------------------------
JLOC Linking Script:
Code:
ALL:
kernel.o
video.o
START: 0,0FF800000
,,code,,kernel.o
CODE: 0
,,code
DATA: 0,#10
,,data
BSS: 0,#10
,,bss
I will clean up the code once the 'inter-modular' functions start working
If anyone is wondering, I got the JLOC script from Johns JLOC/BOOTF/ETC site (the bootf02.zip download)
Any Ideas?
Thanks, Scott
--------------------------------------------------
kernel.c:
Code:
#include "video.h"
char message[]="Welcome to ExOS!";
void init()
{
char *source = message;
char *destination = (char *)0xB8000;
clear_screen();
while (*source) {
*destination++ = *source++;
*destination++ = 0xCE;
}
};
--------------------------------------------------
video.h:
Code:
// Header file for text
// does display functions
// text.h
#if defined( video_h )
//already include
#else
#define video_h
void clear_screen();
#endif
--------------------------------------------------
video.c:
Code:
#include "video.h"
void clear_screen() // clear the entire text screen
{
char *vidmem = (char *)0xB8000;
const long size = 80*25;
long loop;
for (loop=0; loop<size; loop++)
{
*vidmem = ' ';
vidmem++;
*vidmem = 0x07;
vidmem++;
}
}
--------------------------------------------------
LD Linking Script:
Code:
OUTPUT_FORMAT("binary")
ENTRY(_init)
SECTIONS
{
.text 0xFF800000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
--------------------------------------------------
JLOC Linking Script:
Code:
ALL:
kernel.o
video.o
START: 0,0FF800000
,,code,,kernel.o
CODE: 0
,,code
DATA: 0,#10
,,data
BSS: 0,#10
,,bss
I will clean up the code once the 'inter-modular' functions start working