What's wrong with my kernel or other other files or the way I'm attempting to run it?

Joined
May 22, 2010
Messages
2,071
I've always wondered what it would be like to write my own Kernel and beyond. I'm just a Network Admin major with a minor in programming though and I just recently finished writing the sample code in the Modern Assembly book by Daniel Kussworm, which includes the C++ and Assembly sample code for whatever purpose. I wrote the sample code to help me become familiar with writing Assembly optimized C++ programs and read the book, but even though I know how to run both the Assembly and C++ I still don't understand completely what the code is doing yet if I ever will. Also, self teaching yourself the rest of C++ from Tony Gaddis's book is tough and so is doing the same for Assembly optimized C++ programs in Daniel Kussworms books too. You could say this effort might be to ambitious as well.

Anyway I found this guide I how to write a simple sample Kernel here:

http://arjunsreedharan.org/post/82710718100/kernel-101-lets-write-a-kernel

However, even after successfully debugging the code for all the files needed, like the kernel.asm, kernel.c, and link.ld I still can't get the kernel to display "My First Kernel" on boot or in terminal by using qemu and the following is all I get from the output, which flickers this over and over instead of "My First Kernel". Also, grub will not let me edit it on boot if i try to boot to the kernel on the hard disk I saved the files needed to create a kernel to, which just brings up grub rescue mode anyway or either way:

qpilhwc.png


I used the following command to run it as follows and found out how to run a 64-bit Kernel that will follow the previous:

sudo qemu-system-i386 -kernel /mnt/rootpart/kernel

and to run a 64-bit kernel do similar to the following, which also works for a 32-bit kernel:

sudo qemu-system-x86_64 -kernel /mnt/rootpart/kernel
 
Last edited:
Joined
May 22, 2010
Messages
2,071
Here's my code from the kernel.asm file:

;;kernel.asm
bits 32 ;nasm directive - 32-bit
section .text
;multiboot spec
align 4
dd 0x1BADB002 ;magic
dd 0x00 ;flags
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero

global start
extern kmain ;kmain is defined in the c file

start:
cli ;block interrupts
mov esp, stack_space ;set stack pointer
call kmain
hlt: ;halt the CPU

section .bss
resb 8192 ;8kb for stack
stack_space:
 
Joined
May 22, 2010
Messages
2,071
Here is the code from the kernel.c file:

/*
* kernel.c
*/

void kmain(void)
{
const char *str = "my first kernel";
char *vidptr =(char*)0xb8000; //video mem begins here.
unsigned int i = 0;
unsigned int j = 0;

/* this loop clears the screen
* there are 25 lines each of 80 columns; each element takes 2 bytes */
while(j < 80 * 25 * 2) {
/* blank character */
vidptr[j] = ' ';
/* attribute-byte - light grey on black screen */
vidptr[j+1] = 0x07;
j = j + 2;
}

j = 0;

/* this loop writes the string to video memory */
while(str[j] != '\0') {
/* the character's ascii */
vidptr = str[j];
/* attribute-byte: give character black bg light grey fg */
vidptr[i+1] = 0x07;
++j;
i = i + 2;
}
return;
}
 
Joined
May 22, 2010
Messages
2,071
Finally here is the code from the link.ld file:

/*
* link.ld
*/
OUTPUT_FORMAT(elf32-i386)
ENTRY(start)
SECTIONS
{
. = 0x100000;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) }
}
 
Joined
May 22, 2010
Messages
2,071
I made flowcharts for the kernel.asm, kernel.c and lind.ld, but I still haven't been able to make complete sense of whats going on in these programs. I also, had trouble getting libredraw to link the shapes for some reason.
 
Joined
May 22, 2010
Messages
2,071
I also, don't even know where the author expects me to add kernel 201's code into kernel 101's code, even if I should considering I have a minor in programming.
 
Joined
May 22, 2010
Messages
2,071
Ok I got it to a command prompt on another computer if it matters by pressing ctrl-B at boot while running the kernel from the same computer with qemu instead of running the kernel from the a saved location on a hard drive and I'm still using a Live CD to work with as well as compile the kernel and kernel files used to create the kernel. The following picture is what I've got now, but it still doesn't say "My first kernel" at boot and I still need to impliment the code in the kernel 201 guide to make it boot to the prompt it's supposed to boot to:

Pqv3cEd.png
 

BinarySynapse

[H]F Junkie
Joined
Feb 6, 2006
Messages
15,103
from the qemu man page:

This section explains how to launch a Linux kernel inside QEMU without having to make a full bootable image. It is very useful for fast Linux kernel testing.

The syntax is:

qemu-system-i386 -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"

Use -kernel to provide the Linux kernel image and -append to give the kernel command line arguments. The -initrd option can be used to provide an INITRD image.

When using the direct Linux boot, a disk image for the first hard disk hda is required because its boot sector is used to launch the Linux kernel.
 
Joined
May 22, 2010
Messages
2,071
Here's screenshot's of my flowchart for kernel.asm, which I know the shapes need linked though:

WRwfSMR.png


SztiOLb.png


eUODSns.png


PbctuIZ.png


9L4YGE9.png


ypLcEOQ.png
 
Last edited:
Joined
May 22, 2010
Messages
2,071
Finally here's screenshots of the link.ld flowchart, which I know the shapes need link for this flowchart too:

xf2wGry.png


lHonFuw.png
 
Joined
May 22, 2010
Messages
2,071
I made all the flowcharts with Libre Draw instead of Microsoft Visio because I can't afford Visio and get a free subscription validation or whatever even though Microsoft's Imagine program through the University I attend is a pain, especially since I no longer have access to the latest Visio at the site for the school I attends Microsoft Imagine site anyway for some reason. Libre Draw has a shape linker tool, but I had trouble getting it to do what I want and need to check my Libre Office Book or maybe a trusted source on the internet for the solution.
 
Last edited:
Joined
May 22, 2010
Messages
2,071
Nevermind I looked up how to link the shapes and it's actually more obvious than I originally experienced, but Libre Draw makes linking shapes on other pages of flowcharts wierd compared to Visio. However, at least Libre Office does what I need it to do without all the hassle of Visio and at a very affordable price especially compared to other programs that can be used to make flowcharts. Unlike what the guides say though currently, Libre Draw doesn't need glue points though.
 
Joined
May 22, 2010
Messages
2,071
I got the original kernel to post the statement "My first kernel" when loading on my laptop without full bootable img here:

jaduZIg.png


and with full bootable img here:

jUi7daj.png


Now I'm satisfied or proved to myself if not others that it works or at least does something or what it's supposed to do, even if it's not much compared to what others who have actually written more complicated kernels or Operating System code. Therefore, now it's time to work on completing integration of the functions from the kernel 201 guide in to get it to boot to a command prompt.
 
Last edited:
Joined
May 22, 2010
Messages
2,071
I got the kernel.asm to compile correctly using the kernel 201 guide and a little tweeting, but I can't get rid of these errors in the kernel.c:


username@hostname:~$ gcc -m32 -lm -c /home/username/Documents/My\ first\ sample\ kernel/kernel2.c -o /home/username/Documents/My\ first\ sample\ kernel/kc2.o
/home/username/Documents/My first sample kernel/kernel2.c:19:1: warning: parameter names (without types) in function declaration
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), i
^
/home/username/Documents/My first sample kernel/kernel2.c:19:1: warning: parameter names (without types) in function declaration
/home/username/Documents/My first sample kernel/kernel2.c:19:83: error: redefinition of parameter ‘read_port’
handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), int read_port(K
^
/home/username/Documents/My first sample kernel/kernel2.c:19:48: note: previous definition of ‘read_port’ was here
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), i
^
/home/username/Documents/My first sample kernel/kernel2.c:19:134: error: ‘keycode’ undeclared here (not in a function)
_DATA_PORT), int read_port(KEYBOARD_STATUS_PORT) , int keyboard_map[keycode]);
^
/home/username/Documents/My first sample kernel/kernel2.c:20:13: error: ‘current_loc’ undeclared here (not in a function)
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
^
/home/username/Documents/My first sample kernel/kernel2.c:20:30: error: ‘keyboard_map’ undeclared here (not in a function)
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
^
/home/username/Documents/My first sample kernel/kernel2.c:20:43: error: ‘keycode’ undeclared here (not in a function)
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
^
/home/username/Documents/My first sample kernel/kernel2.c: In function ‘kmain’:
/home/username/Documents/My first sample kernel/kernel2.c:26:2: error: unknown type name ‘IDT_entry’
IDT_entry IDT[IDT_SIZE]; // IDT is an IDT_entry structure.
^
/home/username/Documents/My first sample kernel/kernel2.c:26:16: error: ‘IDT_SIZE’ undeclared (first use in this function)
IDT_entry IDT[IDT_SIZE]; // IDT is an IDT_entry structure.
^
/home/username/Documents/My first sample kernel/kernel2.c:26:16: note: each undeclared identifier is reported only once for each function it appears in
/home/username/Documents/My first sample kernel/kernel2.c:30:18: error: ‘write_port’ undeclared (first use in this function)
idt_init(write_port, load_idt, IDT);
^
/home/username/Documents/My first sample kernel/kernel2.c:30:30: error: ‘load_idt’ undeclared (first use in this function)
idt_init(write_port, load_idt, IDT);
^
/home/username/Documents/My first sample kernel/kernel2.c:32:9: warning: parameter names (without types) in function declaration
int keyboard_handler_main(write_port, read_port, keyboard_map);
^
/home/username/Documents/My first sample kernel/kernel2.c:32:13: error: conflicting types for ‘keyboard_handler_main’
int keyboard_handler_main(write_port, read_port, keyboard_map);
^
/home/username/Documents/My first sample kernel/kernel2.c:19:6: note: previous declaration of ‘keyboard_handler_main’ was here
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), i
^
/home/username/Documents/My first sample kernel/kernel2.c: At top level:
/home/username/Documents/My first sample kernel/kernel2.c:60:6: error: conflicting types for ‘idt_init’
void idt_init(void)
^
/home/username/Documents/My first sample kernel/kernel2.c:17:6: note: previous declaration of ‘idt_init’ was here
void idt_init(int write_port, int load_idt, int IDT[]); // function prototype
^
/home/username/Documents/My first sample kernel/kernel2.c: In function ‘idt_init’:
/home/username/Documents/My first sample kernel/kernel2.c:67:36: error: ‘keyboard_handler’ undeclared (first use in this function)
keyboard_address = (unsigned long)keyboard_handler;
^
/home/username/Documents/My first sample kernel/kernel2.c:68:2: error: ‘IDT’ undeclared (first use in this function)
IDT[0x21].offset_lowerbits = keyboard_address & 0xffff;
^
/home/username/Documents/My first sample kernel/kernel2.c:82:2: warning: implicit declaration of function ‘write_port’ [-Wimplicit-function-declaration]
write_port(0x20 , 0x11);
^
/home/username/Documents/My first sample kernel/kernel2.c:110:44: error: ‘IDT_SIZE’ undeclared (first use in this function)
idt_ptr[0] = (sizeof (struct IDT_entry) * IDT_SIZE) +
^
/home/username/Documents/My first sample kernel/kernel2.c:114:2: warning: implicit declaration of function ‘load_idt’ [-Wimplicit-function-declaration]
load_idt(idt_ptr);
^
/home/username/Documents/My first sample kernel/kernel2.c: At top level:
/home/username/Documents/My first sample kernel/kernel2.c:117:6: error: conflicting types for ‘kb_init’
void kb_init(void)
^
/home/username/Documents/My first sample kernel/kernel2.c:18:6: note: previous declaration of ‘kb_init’ was here
void kb_init(int write_port); // function prototype
^
/home/username/Documents/My first sample kernel/kernel2.c:123:6: error: conflicting types for ‘keyboard_handler_main’
void keyboard_handler_main(void) {
^
/home/username/Documents/My first sample kernel/kernel2.c:32:13: note: previous declaration of ‘keyboard_handler_main’ was here
int keyboard_handler_main(write_port, read_port, keyboard_map);
^
/home/username/Documents/My first sample kernel/kernel2.c: In function ‘keyboard_handler_main’:
/home/username/Documents/My first sample kernel/kernel2.c:131:11: warning: implicit declaration of function ‘read_port’ [-Wimplicit-function-declaration]
status = read_port(KEYBOARD_STATUS_PORT);
^
/home/username/Documents/My first sample kernel/kernel2.c:131:21: error: ‘KEYBOARD_STATUS_PORT’ undeclared (first use in this function)
status = read_port(KEYBOARD_STATUS_PORT);
^
/home/username/Documents/My first sample kernel/kernel2.c:135:38: error: ‘KEYBOARD_DATA_PORT’ undeclared (first use in this function)
keycode = read_port(KEYBOARD_DATA_PORT);
^
username@hostname:~$

here's the code for kernel.c using the kernel 201 guide and some necessary tweaking as the author does not tell all the code needed or where it goes:

/*
* kernel.c
*/
#include <stdio.h>
#include <math.h>
struct IDT_entry
{
unsigned short int offset_lowerbits;
unsigned short int selector;
unsigned char zero;
unsigned char type_attr;
unsigned short int offset_higherbits;
};
void idt_init(int write_port, int load_idt, int IDT[]); // function prototype
void kb_init(int write_port); // function prototype
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), int read_port(KEYBOARD_STATUS_PORT) , int keyboard_map[keycode]); // function prototype
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
unsigned long idt_ptr[2]; // Pointer to a unsigned long
void kmain(void)
{
IDT_entry IDT[IDT_SIZE]; // IDT is an IDT_entry structure.
const char *str = "my first kernel";
char *vidptr =(char*)0xb8000; //video mem begins here.
idt_init(write_port, load_idt, IDT);
kb_init(write_port);
int keyboard_handler_main(write_port, read_port, keyboard_map);
unsigned int i = 0;
unsigned int j = 0;
/* this loop clears the screen
* there are 25 lines each of 80 columns; each element takes 2 bytes */
while(j < 80 * 25 * 2) {
/* blank character */
vidptr[j] = ' ';
/* attribute-byte - light grey on black screen */
vidptr[j+1] = 0x07;
j = j + 2;
}
j = 0;
/* this loop writes the string to video memory */
while(str[j] != '\0') {
/* the character's ascii */
vidptr = str[j];
/* attribute-byte: give character black bg light grey fg */
vidptr[i+1] = 0x07;
++j;
i = i + 2;
}
return;
}
void idt_init(void)
{
unsigned long keyboard_address;
unsigned long idt_address;
unsigned long idt_ptr[2];

/* populate IDT entry of keyboard's interrupt */
keyboard_address = (unsigned long)keyboard_handler;
IDT[0x21].offset_lowerbits = keyboard_address & 0xffff;
IDT[0x21].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET
*/
IDT[0x21].zero = 0;
IDT[0x21].type_attr = 0x8e; /* INTERRUPT_GATE */
IDT[0x21].offset_higherbits = (keyboard_address &
0xffff0000) >> 16;
/* Ports
* PIC1 PIC2
*Command 0x20 0xA0
*Data 0x21 0xA1
*/
/* ICW1 - begin initialization */
write_port(0x20 , 0x11);
write_port(0xA0 , 0x11);
/* ICW2 - remap offset address of IDT */
/*
* In x86 protected mode, we have to remap the PICs beyond
0x20 because
* Intel have designated the first 32 interrupts as
"reserved" for cpu exceptions
*/
write_port(0x21 , 0x20);
write_port(0xA1 , 0x28);
/* ICW3 - setup cascading */
write_port(0x21 , 0x00);
write_port(0xA1 , 0x00);
/* ICW4 - environment info */
write_port(0x21 , 0x01);
write_port(0xA1 , 0x01);
/* Initialization finished */
/* mask interrupts */
write_port(0x21 , 0xff);
write_port(0xA1 , 0xff);
/* fill the IDT descriptor */
idt_address = (unsigned long)IDT ;
idt_ptr[0] = (sizeof (struct IDT_entry) * IDT_SIZE) +
((idt_address & 0xffff) << 16);
idt_ptr[1] = idt_address >> 16 ;
load_idt(idt_ptr);
}
void kb_init(void)
{
/* 0xFD is 11111101 - enables only IRQ1 (keyboard)*/
write_port(0x21 , 0xFD);
}
void keyboard_handler_main(void) {
unsigned char status;
char keycode;
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
/* write EOI */
write_port(0x20, 0x20);
status = read_port(KEYBOARD_STATUS_PORT);
/* Lowest bit of status will be set if buffer is not
52 empty */
if (status & 0x01) {
keycode = read_port(KEYBOARD_DATA_PORT);
if(keycode < 0)
return;
vidptr[current_loc++] = keyboard_map[keycode];
vidptr[current_loc++] = 0x07;
}
return;
}



/*
* kernel.c
*/
#include <stdio.h>
#include <math.h>
struct IDT_entry
{
unsigned short int offset_lowerbits;
unsigned short int selector;
unsigned char zero;
unsigned char type_attr;
unsigned short int offset_higherbits;
};
void idt_init(int write_port, int load_idt, int IDT[]); // function prototype
void kb_init(int write_port); // function prototype
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), int read_port(KEYBOARD_STATUS_PORT) , int keyboard_map[keycode]); // function prototype
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
unsigned long idt_ptr[2]; // Pointer to a unsigned long
void kmain(void)
{
IDT_entry IDT[IDT_SIZE]; // IDT is an IDT_entry structure.
const char *str = "my first kernel";
char *vidptr =(char*)0xb8000; //video mem begins here.
idt_init(write_port, load_idt, IDT);
kb_init(write_port);
int keyboard_handler_main(write_port, read_port, keyboard_map);
unsigned int i = 0;
unsigned int j = 0;
/* this loop clears the screen
* there are 25 lines each of 80 columns; each element takes 2 bytes */
while(j < 80 * 25 * 2) {
/* blank character */
vidptr[j] = ' ';
/* attribute-byte - light grey on black screen */
vidptr[j+1] = 0x07;
j = j + 2;
}
j = 0;
/* this loop writes the string to video memory */
while(str[j] != '\0') {
/* the character's ascii */
vidptr = str[j];
/* attribute-byte: give character black bg light grey fg */
vidptr[i+1] = 0x07;
++j;
i = i + 2;
}
return;
}
void idt_init(void)
{
unsigned long keyboard_address;
unsigned long idt_address;
unsigned long idt_ptr[2];

/* populate IDT entry of keyboard's interrupt */
keyboard_address = (unsigned long)keyboard_handler;
IDT[0x21].offset_lowerbits = keyboard_address & 0xffff;
IDT[0x21].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET
*/
IDT[0x21].zero = 0;
IDT[0x21].type_attr = 0x8e; /* INTERRUPT_GATE */
IDT[0x21].offset_higherbits = (keyboard_address &
0xffff0000) >> 16;
/* Ports
* PIC1 PIC2
*Command 0x20 0xA0
*Data 0x21 0xA1
*/
/* ICW1 - begin initialization */
write_port(0x20 , 0x11);
write_port(0xA0 , 0x11);
/* ICW2 - remap offset address of IDT */
/*
* In x86 protected mode, we have to remap the PICs beyond
0x20 because
* Intel have designated the first 32 interrupts as
"reserved" for cpu exceptions
*/
write_port(0x21 , 0x20);
write_port(0xA1 , 0x28);
/* ICW3 - setup cascading */
write_port(0x21 , 0x00);
write_port(0xA1 , 0x00);
/* ICW4 - environment info */
write_port(0x21 , 0x01);
write_port(0xA1 , 0x01);
/* Initialization finished */
/* mask interrupts */
write_port(0x21 , 0xff);
write_port(0xA1 , 0xff);
/* fill the IDT descriptor */
idt_address = (unsigned long)IDT ;
idt_ptr[0] = (sizeof (struct IDT_entry) * IDT_SIZE) +
((idt_address & 0xffff) << 16);
idt_ptr[1] = idt_address >> 16 ;
load_idt(idt_ptr);
}
void kb_init(void)
{
/* 0xFD is 11111101 - enables only IRQ1 (keyboard)*/
write_port(0x21 , 0xFD);
}
void keyboard_handler_main(void) {
unsigned char status;
char keycode;
char vidptr[current_loc++] = keyboard_map[keycode]; // Pointer to a char
/* write EOI */
write_port(0x20, 0x20);
status = read_port(KEYBOARD_STATUS_PORT);
/* Lowest bit of status will be set if buffer is not
52 empty */
if (status & 0x01) {
keycode = read_port(KEYBOARD_DATA_PORT);
if(keycode < 0)
return;
vidptr[current_loc++] = keyboard_map[keycode];
vidptr[current_loc++] = 0x07;
}
return;
}
 
Joined
May 22, 2010
Messages
2,071
Here's the code for kernel.asm using the kernel 201 guide and a little tweeking for the same reasons I mentioned in the kernel.c, but the kernel.asm didn't take me as long to successfully compile as the kernel.c is:


;;kernel.asm
bits 32 ;nasm directive - 32-bit
section .text
;multiboot spec
align 4
dd 0x1BADB002 ;magic
dd 0x00 ;flags
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero
global start
extern kmain ;kmain is defined in the c file
extern keyboard_handler_main ;kmain is defined in the c file
start:
cli ;block interrupts
mov esp, stack_space ;set stack pointer
call kmain
hlt: ;halt the CPU

read_port:
mov edx, [esp + 4]
in al, dx
ret
write_port:
mov edx, [esp + 4]
mov al, [esp + 4 + 4]
out dx, al
ret
load_idt:
call idt_init
mov edx, [esp + 4]
lidt [edx]
sti
ret
idt_init:
call idt_init
ret
kb_init:
call kb_init
ret
keyboard_handler:
call keyboard_handler_main
iretd
section .bss
resb 8192 ;8kb for stack
stack_space:
 
Joined
May 22, 2010
Messages
2,071
I know HF probably isn't the place to ask for coding help either, which I'm not really. However, if it seems like it and I'm not allowed to I hope I don't get banned for at least posting my code here for at least some advice if not on coding.
 

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
6,695
Isn't there a 'code tag' option in the editor under the + sign?
 

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
6,695
Your errors seem fairly straight forward... read'em!

Example:

warning: parameter names (without types) in function declaration
void keyboard_handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), i

You are using a parameter without a type.. I don't know.. maybe that 'KEYBOARD_DATA_PORT' would be a good place to start. Did you forget a '#define KEYBOARD_DATA_PORT 0x60' or something at the top?

redefinition of parameter ‘read_port’
handler_main(int write_port, int read_port(KEYBOARD_DATA_PORT), int read_port(K
Like any other programming language - having two parameters named the same thing is bad.. so having two 'read_port' parameters is a no-no.

: error: ‘keycode’ undeclared here (not in a function)
_DATA_PORT), int read_port(KEYBOARD_STATUS_PORT) , int keyboard_map[keycode]);
You have a variable name in a method header and you haven't defined it. So define it!

.. etc
 
Joined
May 22, 2010
Messages
2,071
Your errors seem fairly straight forward... read'em!

Example:



You are using a parameter without a type.. I don't know.. maybe that 'KEYBOARD_DATA_PORT' would be a good place to start. Did you forget a '#define KEYBOARD_DATA_PORT 0x60' or something at the top?


Like any other programming language - having two parameters named the same thing is bad.. so having two 'read_port' parameters is a no-no.


You have a variable name in a method header and you haven't defined it. So define it!

.. etc

Yes I know my errors seems pretty straight forward, but I've never written a kernel before this or even this advanced regardless if this isn't even that advanced yet and everything I've tried hasn't worked. Also, I don't know what I'm missing or haven't tried either, so I need help figuring it out regardless if I can't get help on HF.
 

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
6,695
What's your programming background? Parameter names must be unique..including any defines are crucial.. etc.
 
Joined
May 22, 2010
Messages
2,071
What's your programming background? Parameter names must be unique..including any defines are crucial.. etc.

I have a minor in computer programming from taking C++, Visual Basic.Net, Java, and HTML, which I know HTML is not usually considered a programming language. I know parameters need to be unique as almost all code or variable do too as well, but I didn't know, which parameters I didn't make unique.

It was pointed out to me on another forum geared more towards coding that the following was not unique:

"void keyboard_handler_main(int write_port(unsigned short port,
unsigned char data), int read_port(KEYBOARD_DATA_PORT), int keyboard_map[keycode]); // function prototype"

and should be this:

"void keyboard_handler_main(void); // function prototype"

, but what about these function prototype parameters:


"void idt_init(int write_port, int load_idt, int IDT[]); // function prototype

void kb_init(int write_port); // function prototype"

Should they be the following:

"
void idt_init(void); // function prototype

void kb_init(void); // function prototype"

I can see how there parameters wouldn't be unique though as I originallly had them because this:

"void idt_init(int write_port, int load_idt, int IDT[]); // function prototype"

and this:

"void kb_init(int write_port); // function prototype"

contain this as at least one of the parameters:

"int write_port"

,but I don't know if these parameters should be void or what they should be if not similar to what I had them as.
 

modi123

Supreme [H]ardness
Joined
Sep 6, 2006
Messages
6,695
As addressed in the other forum - you haven't declared or gave datatypes to.. many of those parameter parts.
 
Joined
May 22, 2010
Messages
2,071
Do worry about it I found that the problem was that I tried to mix this code together from kernel 101 and kernel 201, which gave me nothing but problems because I don't know the correct syntax and my books are probably outdated.
 
Top