[LinksOS CVS Commit]linksos/main cmain.c,NONE,1.1 io.c,1.2,1.3 Makefile,1.6,1.7 kstdio.c,1.3,1.4 mai
Status: Inactive
Brought to you by:
terencevs
|
From: <bg...@us...> - 2003-01-26 11:31:54
|
Update of /cvsroot/linksos/linksos/main
In directory sc8-pr-cvs1:/tmp/cvs-serv2091/main
Modified Files:
Makefile kstdio.c
Added Files:
cmain.c io.c
Removed Files:
main.c strap.asm
Log Message:
Title: Rebuild of CVS
Changes: Added license and returned code that was removed
Effects: We now have a bootable hello world kernel with correct copyright notice
a=n/a b=n/a
--- NEW FILE: cmain.c ---
/*
Copyright (c) 2003, LinksOS Developer Team
All rights reserved.
*/
#include <multiboot.h>
#include "include/kstdio.h"
#include "include/gdt.h"
desc_table(GDT, 3)
{
{dummy:0},
stnd_desc(0, 0xFFFFF, (D_CODE + D_READ + D_BIG + D_BIG_LIM)),
stnd_desc(0, 0xFFFFF, (D_DATA + D_WRITE + D_BIG + D_BIG_LIM)),
};
struct
{
unsigned short limit __attribute__ ((packed));
union DT_entry *gdt __attribute__ ((packed));
} loadgdt = { (4096 * sizeof(union DT_entry) - 1), GDT };
void cmain(unsigned long magic, multiboot_info_t addr)
{
if(magic != MULTIBOOT_BOOTLOADER_MAGIC){
kprintf("Invalid bootloader magic number\n");
return;
}
/*Load GDT*/
asm ("pushl $2; popf"); /* Zero the flags */
asm volatile /* Load the GDT and the kernel stack */
( /* Loader has cleared ints */
"lgdtl (loadgdt) \n" /* Load our own GDT */
"movw $0x10,%%ax \n" /* Init data registers t_data */
"movw %%ax,%%ds \n"
"movw %%ax,%%es \n"
"movw %%ax,%%fs \n"
"movw %%ax,%%gs \n"
"ljmp $0x08,$next \n" /* Flush prefetch queue */
"nop\n"
"nop\n"
"next: \n" /* Continue here */
:
: "r" (GDT)
: "%eax"
);
kprintf("LinksOS v0.0.1a kernel booted.\nI'll loop forever now.\n");
}
Index: Makefile
===================================================================
RCS file: /cvsroot/linksos/linksos/main/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile 1 Jan 2003 07:27:39 -0000 1.6
--- Makefile 26 Jan 2003 11:31:50 -0000 1.7
***************
*** 7,39 ****
GCC = gcc
- #The assembler
- ASM = nasm
-
- # The linker
- LD = ld
-
- # The kernel filename
- KERNELFN = kernel.bin
-
# The object files
! OBJS = kstdio.o main.o strap.o
#Compiler parameters
CFLAGS = -I$(INCLUDE) -Wall -O -fomit-frame-pointer -c -o
- ASMFLAGS = -f elf
-
-
- .SUFFIXES: .asm
-
- ALL: $(KERNELFN)
! $(KERNELFN): $(OBJS)
! $(LD) -Bstatic -o $(KERNELFN) $(OBJS) -Map kernel.map -T kernel.ls
.c.o:
$(CC) $(CFLAGS) $@ $<
-
- .asm.o:
- $(ASM) $(ASMFLAGS) $<
clean:
--- 7,23 ----
GCC = gcc
# The object files
! OBJS = kstdio.o cmain.o io.o
!
! #Include
! INCLUDE = ../include
#Compiler parameters
CFLAGS = -I$(INCLUDE) -Wall -O -fomit-frame-pointer -c -o
! ALL: $(OBJS)
.c.o:
$(CC) $(CFLAGS) $@ $<
clean:
Index: kstdio.c
===================================================================
RCS file: /cvsroot/linksos/linksos/main/kstdio.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** kstdio.c 1 Jan 2003 07:27:39 -0000 1.3
--- kstdio.c 26 Jan 2003 11:31:50 -0000 1.4
***************
*** 1,17 ****
! /****************************************************************************\
! ** filename: kstdio.c **
! ** creation date: 11/29/2002, 0109 MST **
! ** author: Charles Banas **
! ** version: 0.01 **
! ******************************************************************************
! ** revision history: **
! ** 11/29/2002 - 0109 MST - Charles **
! ** added kprintf(). let's see if this baby links, eh. **
! \****************************************************************************/
#include "include/kstdio.h"
!
! typedef unsigned char u_char; /* this needs to be moved to a "types"
! header file. */
void kprintf(char* text)
--- 1,10 ----
! /*
! Copyright (c) 2003, LinksOS Developer Team
! All rights reserved.
! */
+ #include <types.h>
#include "include/kstdio.h"
! #include "include/io.h"
void kprintf(char* text)
***************
*** 24,45 ****
{
/* write 'text' to screen. */
! static char* screen = (char*)0xB8000;
! int j;
! static int i = 0;
! static u_char prev;
- for(j=0;text[j]!=0;++i,j++) { /* don't be scared. it's kosher. :) */
- if (((text[j]==0xa) || (text[j]==0xd)) && ((prev==0xa) || (prev==0xd))) {
- continue;
- prev = text[j];
- }
- else if ((text[j]==0xa) || (text[j]==0xd)) {
- i = i + (0xa0);
- prev = text[j];
- continue;
- }
- prev = text[j];
- screen[i*2] = text[j];
- screen[i*2+1] = 7;
- }
}
--- 17,73 ----
{
/* write 'text' to screen. */
! static u_char *screen = (u_char*)0xB8000;
! static int curchar,off;
!
! /*First get the cursor's current position on screen*/
! outportb(0x3d4, 0x0e); /* Get cursor Y position */
! off = inportb(0x3d5);
! off <<= 8;
! outportb(0x3d4, 0x0f); /* And add cursor X position */
! off += inportb(0x3d5);
! off <<= 1;
!
! while((curchar = *text++)){ /*Process text char by char*/
! switch(curchar){
!
! case '\n': /*It is a carriage return*/
! off = 160 + (off/160)*160;
! break;
!
! default: /*Just spit character onto screen*/
! screen[off++] = curchar;
! screen[off++] = 0x07;
! }
! }
!
! /*Move cursor to new screen position*/
! off >>= 1;
! outportb(0x3d4,0x0f);
! outportb(0x3d5,off & 0x0ff);
! outportb(0x3d4,0x0e);
! outportb(0x3d5,off >> 8);
! }
!
!
! /*
! l2str: Converts long or int (if you cast) to a string.
! */
! void l2str(unsigned char *dest, unsigned long num)
! {
! unsigned char j=0,i;
! u_char tmp;
!
! do{
! dest[j++]=48+(num%10); /*Get the ascii code of the digit*/
! num = num / 10;
! }while(num);
! dest[j--]='\0'; /*Null terminate the string*/
!
! /*But now dest is reversed so reverse it*/
! for(i=0;i<=j;--j,i++){
! tmp=dest[i];
! dest[i]=dest[j];
! dest[j]=tmp;
! }
}
--- main.c DELETED ---
--- strap.asm DELETED ---
|