OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 9:07 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
I have made my keyboard.h and imported the code that implements everything needed for terminal_writestring and terminal_writestring, and terminal_initialize, and a file that defines inb/outb and many other functions.

However, since my keyboard.h is extremely large, i would want to know if it actually works.
Here are it's functions:
It includes a enum containing all the scancodes of:
the entire 26 letter alphabet, not uppercase/lowercase since the scan code table does not say that, scan code type/table 1
equal sign (=), point (.), single quote ('), slash (/) and all numbers from 0 to 9.
and:
a get scan code function copied from the OSDev website
and a write letter if scan code = anything from the enums that is not
Code:
int a; a="qwertyuiop"
and is instead
Code:
getkey(){
if key = A then print A
if key = B then print B...
if key = equalsign then print =



Here's the code:
Code:
enum scancodedata {
   AP_SCD = 0x1E,
   BP_SCD = 0x30,
   CP_SCD = 0x2E,
   DP_SCD = 0x20,
   EP_SCD = 0x12,
   FP_SCD = 0x21,
   GP_SCD = 0x22,
   HP_SCD = 0x23,
   IP_SCD = 0x17,
   JP_SCD = 0x24,
   KP_SCD = 0x25,
   LP_SCD = 0x26,
   MP_SCD = 0x32,
   NP_SCD = 0x31,
   OP_SCD = 0x18,
   PP_SCD = 0x19,
   QP_SCD = 0x10,
   RP_SCD = 0x13,
   SP_SCD = 0x1F,
   TP_SCD = 0x14,
   UP_SCD = 0x16,
   VP_SCD = 0x2F,
   WP_SCD = 0x11,
   XP_SCD = 0x2D,
   YP_SCD = 0x15,
   ZP_SCD = 0x2C,
   ENTERP_SCD = 0x1C,
   1P_SCD = 0x02,
   2P_SCD = 0x03,
   3P_SCD = 0x04,
   4P_SCD = 0x05,
   5P_SCD = 0x06,
   6P_SCD = 0x07,
   7P_SCD = 0x08,
   8P_SCD = 0x09,
   9P_SCD = 0x0A,
   0P_SCD = 0x0B,
   SLASHP_SCD = 0x35,
   POINTP_SCD = 0x34,
   SINGQUOTP_SCD = 0x28,
   EQUALP_SCD = 0x0D,
   /* SCD = Scan Code Data
   (X)P = (X)Pressed */
};
char getScancode()
{
char c=0;
do {
if(inb(0x60)!=c)
{
c=inb(0x60);
if(c>0)
return c;
}
}while(1);
}
char getchar()
{
return scancode[getScancode()+1];
}
int
getKey()
{
   getScancode();
   if (scancode == AP_SCD)
   {
      terminal_writestring("A");
   }
   if (scancode == BP_SCD)
   {
      terminal_writestring("B");
   }
   if (scancode == CP_SCD)
   {
      terminal_writestring("C");
   }
   if (scancode == DP_SCD)
   {
      terminal_writestring("D");
   }
   if (scancode == EP_SCD)
   {
      terminal_writestring("E");
   }
   if (scancode == FP_SCD)
   {
      terminal_writestring("F");
   }
   if (scancode == GP_SCD)
   {
      terminal_writestring("G");
   }
   if (scancode == HP_SCD)
   {
      terminal_writestring("H");
   }
   if (scancode == IP_SCD)
   {
      terminal_writestring("I");
   }
   if (scancode == JP_SCD)
   {
      terminal_writestring("J");
   }
   if (scancode == KP_SCD)
   {
      terminal_writestring("K");
   }
   if (scancode == LP_SCD)
   {
      terminal_writestring("L");
   }
   if (scancode == MP_SCD)
   {
      terminal_writestring("M");
   }
   if (scancode == NP_SCD)
   {
      terminal_writestring("N");
   }
   if (scancode == OP_SCD)
   {
      terminal_writestring("O");
   }
   if (scancode == PP_SCD)
   {
      terminal_writestring("P");
   }
   if (scancode == QP_SCD)
   {
      terminal_writestring("Q");
   }
   if (scancode == RP_SCD)
   {
      terminal_writestring("R");
   }
   if (scancode == SP_SCD)
   {
      terminal_writestring("S");
   }
   if (scancode == TP_SCD)
   {
      terminal_writestring("T");
   }
   if (scancode == UP_SCD)
   {
      terminal_writestring("U");
   }
   if (scancode == VP_SCD)
   {
      terminal_writestring("V");

   }
   if (scancode == WP_SCD)
   {
      terminal_writestring("W");

   }
   if (scancode == XP_SCD)
   {
      terminal_writestring("X");

   }
   if (scancode == YP_SCD)
   {
      terminal_writestring("Y");

   }
   if (scancode == ZP_SCD)
   {
      terminal_writestring("Z");

   }
   if (scancode == ENTERP_SCD)
   {
      terminal_row = terminal_row++;
      terminal_column = 0;
      

   }
   if (scancode == 1P_SCD)
   {
      terminal_writestring("1");

   }
   if (scancode == 2P_SCD)
   {
      terminal_writestring("2");

   }
   if (scancode == 3P_SCD)
   {
      terminal_writestring("3");

   }
   if (scancode == 4P_SCD)
   {
      terminal_writestring("4");

   }
   if (scancode == 5P_SCD)
   {
      terminal_writestring("5");

   }
   if (scancode == 6P_SCD)
   {
      terminal_writestring("6");

   }
   if (scancode == 7P_SCD)
   {
      terminal_writestring("7");

   }
   if (scancode == 8P_SCD)
   {
      terminal_writestring("8");

   }
   if (scancode == 9P_SCD)
   {
      terminal_writestring("9");

   }
   if (scancode == 0P_SCD)
   {
      terminal_writestring("0");

   }
   if (scancode == SLASHP_SCD)
   {
      terminal_writestring("/");

   }
   if (scancode == POINTP_SCD)
   {
      terminal_writestring(".");

   }
   if (scancode == SINGQUOTP_SCD)
   {
      terminal_writestring("'");

   }
   if (scancode == EQUALP_SCD)
   {
      terminal_writestring("=");

   }
}

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 9:53 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
It's not good practice to include code in header files. Use them for function declarations, macros, constants, and the like.

(Like all rules, there are exceptions - but not the kind of abuse that we see here.)

There are too many errors and examples of bad style in the code itself for me to comment on it. I would really suggest that you learn C before attempting to use it to write an operating system. It's beyond the scope of this forum to provide a C tutorial.


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 10:07 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
Why don't you use an array for the scancodes-ASCII mappings?
As already stated, you should probably learn C before writing an OS in it.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 10:08 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
iansjack wrote:
It's not good practice to include code in header files. Use them for function declarations, macros, constants, and the like.

(Like all rules, there are exceptions - but not the kind of abuse that we see here.)

There are too many errors and examples of bad style in the code itself for me to comment on it. I would really suggest that you learn C before attempting to use it to write an operating system. It's beyond the scope of this forum to provide a C tutorial.

What is wrong?
(I know about the include parts and everything else missing. That's intentional, i only wanted to provide the actual code and not other stuff).

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 10:56 am 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
What's going on with your formatting? ](*,)
Anyway, if you want to know if it works or not why don't you just test it yourself?

_________________
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 12:30 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
zenzizenzicube wrote:
What's going on with your formatting? ](*,)
Anyway, if you want to know if it works or not why don't you just test it yourself?

meh, time to compile

edit:
Code:
error scancode undefined:
return scancode[getScancode()+1];


then edit the freaking code OSDev, that's part of the get scan code function.

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Last edited by NunoLava1998 on Sat Nov 12, 2016 12:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 12:33 pm 
Offline
Member
Member

Joined: Wed Jun 17, 2015 9:40 am
Posts: 501
Location: Athens, Greece
Hi,


NunoLava1998 wrote:
zenzizenzicube wrote:
What's going on with your formatting? ](*,)
Anyway, if you want to know if it works or not why don't you just test it yourself?
meh, time to compile
So you didn't even compile your code before posting it here? Do you at least have a general algorithm or a general design we could comment on?


Regards,
glauxosdever


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 12:59 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
glauxosdever wrote:
Hi,


NunoLava1998 wrote:
zenzizenzicube wrote:
What's going on with your formatting? ](*,)
Anyway, if you want to know if it works or not why don't you just test it yourself?
meh, time to compile
So you didn't even compile your code before posting it here? Do you at least have a general algorithm or a general design we could comment on?


Regards,
glauxosdever

Yes.
I first set up a enum for easier reading and to not make this take more time.
I then set up a scan code get (inb/outb IS imported) and a key get which displays the pressed key as long it is in the list.
Here are the full list of errors/warnings/notes:

Code:
terminalf/fkbd.h:44:2: error: invalid suffix "P_SCD" on integer constant
  1P_SCD = 0x02,
  ^
terminalf/fkbd.h:44:2: error: expected identifier before numeric constant
terminalf/fkbd.h:45:2: error: invalid suffix "P_SCD" on integer constant
  2P_SCD = 0x03,
  ^
terminalf/fkbd.h:46:2: error: invalid suffix "P_SCD" on integer constant
  3P_SCD = 0x04,
  ^
terminalf/fkbd.h:47:2: error: invalid suffix "P_SCD" on integer constant
  4P_SCD = 0x05,
  ^
terminalf/fkbd.h:48:2: error: invalid suffix "P_SCD" on integer constant
  5P_SCD = 0x06,
  ^
terminalf/fkbd.h:49:2: error: invalid suffix "P_SCD" on integer constant
  6P_SCD = 0x07,
  ^
terminalf/fkbd.h:50:2: error: invalid suffix "P_SCD" on integer constant
  7P_SCD = 0x08,
  ^
terminalf/fkbd.h:51:2: error: invalid suffix "P_SCD" on integer constant
  8P_SCD = 0x09,
  ^
terminalf/fkbd.h:52:2: error: invalid suffix "P_SCD" on integer constant
  9P_SCD = 0x0A,
  ^
terminalf/fkbd.h:53:2: error: invalid suffix "P_SCD" on integer constant
  0P_SCD = 0x0B,
  ^
terminalf/fkbd.h: In function 'getchar':
terminalf/fkbd.h:73:8: error: 'scancode' undeclared (first use in this function)
return scancode[getScancode()+1];
        ^
terminalf/fkbd.h:73:8: note: each undeclared identifier is reported only once for each function it appears in
terminalf/fkbd.h: In function 'getKey':
terminalf/fkbd.h:79:6: error: 'scancode' undeclared (first use in this function)
  if (scancode == AP_SCD)
      ^
terminalf/fkbd.h:190:16: warning: operation on 'terminal_row' may be undefined [-Wsequence-point]
   terminal_row = terminal_row++;
                ^
terminalf/fkbd.h:195:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 1P_SCD)
                  ^
terminalf/fkbd.h:200:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 2P_SCD)
                  ^
terminalf/fkbd.h:205:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 3P_SCD)
                  ^
terminalf/fkbd.h:210:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 4P_SCD)
                  ^
terminalf/fkbd.h:215:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 5P_SCD)
                  ^
terminalf/fkbd.h:220:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 6P_SCD)
                  ^
terminalf/fkbd.h:225:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 7P_SCD)
                  ^
terminalf/fkbd.h:230:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 8P_SCD)
                  ^
terminalf/fkbd.h:235:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 9P_SCD)
                  ^
terminalf/fkbd.h:240:18: error: invalid suffix "P_SCD" on integer constant
  if (scancode == 0P_SCD)
                  ^
terminalf/fkbd.h:245:18: error: 'SLASHP_SCD' undeclared (first use in this function)
  if (scancode == SLASHP_SCD)
                  ^
terminalf/fkbd.h:250:18: error: 'POINTP_SCD' undeclared (first use in this function)
  if (scancode == POINTP_SCD)
                  ^
terminalf/fkbd.h:255:18: error: 'SINGQUOTP_SCD' undeclared (first use in this function)
  if (scancode == SINGQUOTP_SCD)
                  ^
terminalf/fkbd.h:260:18: error: 'EQUALP_SCD' undeclared (first use in this function)
  if (scancode == EQUALP_SCD)
                  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h: At top level:
terminalf/printservices.h:20:6: error: nested redefinition of 'enum vga_color'
enum vga_color {
      ^
terminalf/printservices.h:20:6: error: redeclaration of 'enum vga_color'
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:20:6: note: originally defined here
enum vga_color {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:21:2: error: redeclaration of enumerator 'VGA_COLOR_BLACK'
  VGA_COLOR_BLACK = 0,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:21:2: note: previous definition of 'VGA_COLOR_BLACK' was here
  VGA_COLOR_BLACK = 0,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:22:2: error: redeclaration of enumerator 'VGA_COLOR_BLUE'
  VGA_COLOR_BLUE = 1,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:22:2: note: previous definition of 'VGA_COLOR_BLUE' was here
  VGA_COLOR_BLUE = 1,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:23:2: error: redeclaration of enumerator 'VGA_COLOR_GREEN'
  VGA_COLOR_GREEN = 2,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:23:2: note: previous definition of 'VGA_COLOR_GREEN' was here
  VGA_COLOR_GREEN = 2,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:24:2: error: redeclaration of enumerator 'VGA_COLOR_CYAN'
  VGA_COLOR_CYAN = 3,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:24:2: note: previous definition of 'VGA_COLOR_CYAN' was here
  VGA_COLOR_CYAN = 3,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:25:2: error: redeclaration of enumerator 'VGA_COLOR_RED'
  VGA_COLOR_RED = 4,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:25:2: note: previous definition of 'VGA_COLOR_RED' was here
  VGA_COLOR_RED = 4,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:26:2: error: redeclaration of enumerator 'VGA_COLOR_MAGENTA'
  VGA_COLOR_MAGENTA = 5,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:26:2: note: previous definition of 'VGA_COLOR_MAGENTA' was here
  VGA_COLOR_MAGENTA = 5,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:27:2: error: redeclaration of enumerator 'VGA_COLOR_BROWN'
  VGA_COLOR_BROWN = 6,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:27:2: note: previous definition of 'VGA_COLOR_BROWN' was here
  VGA_COLOR_BROWN = 6,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:28:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_GREY'
  VGA_COLOR_LIGHT_GREY = 7,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:28:2: note: previous definition of 'VGA_COLOR_LIGHT_GREY' was here
  VGA_COLOR_LIGHT_GREY = 7,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:29:2: error: redeclaration of enumerator 'VGA_COLOR_DARK_GREY'
  VGA_COLOR_DARK_GREY = 8,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:29:2: note: previous definition of 'VGA_COLOR_DARK_GREY' was here
  VGA_COLOR_DARK_GREY = 8,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:30:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_BLUE'
  VGA_COLOR_LIGHT_BLUE = 9,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:30:2: note: previous definition of 'VGA_COLOR_LIGHT_BLUE' was here
  VGA_COLOR_LIGHT_BLUE = 9,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:31:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_GREEN'
  VGA_COLOR_LIGHT_GREEN = 10,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:31:2: note: previous definition of 'VGA_COLOR_LIGHT_GREEN' was here
  VGA_COLOR_LIGHT_GREEN = 10,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:32:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_CYAN'
  VGA_COLOR_LIGHT_CYAN = 11,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:32:2: note: previous definition of 'VGA_COLOR_LIGHT_CYAN' was here
  VGA_COLOR_LIGHT_CYAN = 11,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:33:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_RED'
  VGA_COLOR_LIGHT_RED = 12,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:33:2: note: previous definition of 'VGA_COLOR_LIGHT_RED' was here
  VGA_COLOR_LIGHT_RED = 12,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:34:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_MAGENTA'
  VGA_COLOR_LIGHT_MAGENTA = 13,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:34:2: note: previous definition of 'VGA_COLOR_LIGHT_MAGENTA' was here
  VGA_COLOR_LIGHT_MAGENTA = 13,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:35:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_BROWN'
  VGA_COLOR_LIGHT_BROWN = 14,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:35:2: note: previous definition of 'VGA_COLOR_LIGHT_BROWN' was here
  VGA_COLOR_LIGHT_BROWN = 14,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:36:2: error: redeclaration of enumerator 'VGA_COLOR_WHITE'
  VGA_COLOR_WHITE = 15,
  ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:36:2: note: previous definition of 'VGA_COLOR_WHITE' was here
  VGA_COLOR_WHITE = 15,
  ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:39:23: error: redefinition of 'vga_entry_color'
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
                       ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:39:23: note: previous definition of 'vga_entry_color' was here
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) {
                       ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:43:24: error: redefinition of 'vga_entry'
static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
                        ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:43:24: note: previous definition of 'vga_entry' was here
static inline uint16_t vga_entry(unsigned char uc, uint8_t color) {
                        ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:47:8: error: redefinition of 'strlen'
size_t strlen(const char* str) {
        ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:47:8: note: previous definition of 'strlen' was here
size_t strlen(const char* str) {
        ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:54:21: error: redefinition of 'VGA_WIDTH'
static const size_t VGA_WIDTH = 80;
                     ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:54:21: note: previous definition of 'VGA_WIDTH' was here
static const size_t VGA_WIDTH = 80;
                     ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:55:21: error: redefinition of 'VGA_HEIGHT'
static const size_t VGA_HEIGHT = 25;
                     ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:55:21: note: previous definition of 'VGA_HEIGHT' was here
static const size_t VGA_HEIGHT = 25;
                     ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:62:6: error: redefinition of 'terminal_initialize'
void terminal_initialize(void) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:62:6: note: previous definition of 'terminal_initialize' was here
void terminal_initialize(void) {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:75:6: error: redefinition of 'terminal_setcolor'
void terminal_setcolor(uint8_t color) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:75:6: note: previous definition of 'terminal_setcolor' was here
void terminal_setcolor(uint8_t color) {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:79:6: error: redefinition of 'terminal_putentryat'
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:79:6: note: previous definition of 'terminal_putentryat' was here
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:84:6: error: redefinition of 'terminal_putchar'
void terminal_putchar(char c) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:84:6: note: previous definition of 'terminal_putchar' was here
void terminal_putchar(char c) {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:93:6: error: redefinition of 'terminal_write'
void terminal_write(const char* data, size_t size) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:93:6: note: previous definition of 'terminal_write' was here
void terminal_write(const char* data, size_t size) {
      ^
In file included from terminalf/f.c:7:0,
                 from kernel.c:8:
terminalf/printservices.h:98:6: error: redefinition of 'terminal_writestring'
void terminal_writestring(const char* data) {
      ^
In file included from terminalf/fkbd.h:6:0,
                 from terminalf/f.c:6,
                 from kernel.c:8:
terminalf/printservices.h:98:6: note: previous definition of 'terminal_writestring' was here
void terminal_writestring(const char* data) {
      ^
In file included from terminalf/f.c:6:0,
                 from kernel.c:8:
terminalf/fkbd.h: In function 'getchar':
terminalf/fkbd.h:74:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
terminalf/fkbd.h: In function 'getKey':
terminalf/fkbd.h:265:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^


(the majority are warnings that don't even make sense)

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 1:16 pm 
Offline
Member
Member

Joined: Wed Jun 17, 2015 9:40 am
Posts: 501
Location: Athens, Greece
Hi,


You have comprehension issues, I think. I didn't ask for a long list of warnings/errors. I asked if you have a general design for the keyboard driver. Besides, the causes of these warnings/errors should be evident.

But to answer why you get these errors...
  • Identifiers (variable names in this case) shall not start with a number digit.
  • There are a lot of variables undeclared (or worse uninitialised - the compiler may or may not detect them!).
  • Many constants and functions are redeclared or redefined.
  • Missing return statements at the end of functions.

And you can't really have an informed opinion about whether warnings/errors make sense or not. You don't have enough experience.


Regars,
glauxosdever


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 1:27 pm 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
Quote:
(the majority are warnings that don't even make sense)
That could be interpreted as a slight insult to compiler writers (an undeserved one since the issues do make sense).

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 1:33 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Just go away and learn C rather than polluting this forum with silly posts.


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 2:16 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
NunoLava1998 wrote:
What is wrong?

I recommend reading WhyNeverToPlaceFunctionsInIncludeHeaders to understand why putting code in included files is a Bad Idea.

NunoLava1998 wrote:
(I know about the include parts and everything else missing. That's intentional, i only wanted to provide the actual code and not other stuff).


I honestly don't know how to parse this statement, though I do get from it - and the fact that you are posting the code here instead of a link to your repo - that you still don't have an offsite version control repository set up.

whacks NumaNuma with Yoda's cane If listen you do not, learn you never shall!

NunoLava1998 wrote:
then edit the freaking code OSDev, that's part of the get scan code function.


Wait, did you just tell us to fix your code? I think you have the wrong idea of what this forum is about. There is no more a royal road to operating system development today than there was one to geometry in Euclid's time (there still isn't, for that matter).

You need to fix it yourself. You can ask us for help and advice, and go to the wiki for information, but it is not our OS project that needs fixing, it is yours. We can't do that, even if we wanted to, because if we did it wouldn't be your OS. It would completely invalidate the goal of this site, which is to learn, to teach, and to learn some more. For most us here, the OS itself isn't the goal, it is the learning process; and for those who do see the OS as the goal, they generally want it to be their operating system code, not some Frankenstein monster of code sewn together from the corpses of existing OSes.

You really need to consider what you want out of posting here. If it is anything more than a trollish laugh from the reactions you get, then you have to, as the Dark Souls players say, Get Good. We can help you with that, but we won't write your OS for you.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Last edited by Schol-R-LEA on Sat Nov 12, 2016 2:28 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sat Nov 12, 2016 2:20 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
I'd have to say that this thread reinforces my view that this user is a troll.

No doubt Brendan will be along in a minute to tell us that we are being unfair and should explain his errors one by one. Until the next time. And the next. And....


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Sun Nov 13, 2016 1:02 pm 
Offline
Member
Member
User avatar

Joined: Mon Dec 28, 2015 11:11 am
Posts: 401
It seems to be terrible practice to use 200 IFs in each GetChar(), while it does not return anything even when the function is non-void, copying GetScancode() and probably inb() and outb() from wiki, telling people useless stuff like:
Quote:
a get scan code function copied from the OSDev website
and a write letter if scan code = anything from the enums that is not
Code:
int a; a="qwertyuiop"


It may be good idea to use interrupts instead getScancode() and use arrays instead 200 IFs.
Enums are evil, instead use #define .


Top
 Profile  
 
 Post subject: Re: Does my keyboard.h work?
PostPosted: Mon Nov 14, 2016 12:59 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
Made another one.
ERRORS WHEN COMPILING:
Code:
kbd.c: In function 'scancoderec':
kbd.c:57:11: warning: incompatible implicit declaration of built-in function 'strlen' [enabled by default]
  ScanCode[strlen(ValEAX)-8] = '\0'; /* Remove last 8 bits from the value we gathered from EAX to get AH and make that the scancode. */
           ^
kbd.c:57:2: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast [enabled by default]
  ScanCode[strlen(ValEAX)-8] = '\0'; /* Remove last 8 bits from the value we gathered from EAX to get AH and make that the scancode. */
  ^
kbd.c:57:2: note: expected 'const char *' but argument is of type 'int'
kbd.c:57:10: error: subscripted value is neither array nor pointer nor vector
  ScanCode[strlen(ValEAX)-8] = '\0'; /* Remove last 8 bits from the value we gathered from EAX to get AH and make that the scancode. */
          ^
kbd.c: In function 'keyrec':
kbd.c:62:6: warning: assignment makes pointer from integer without a cast [enabled by default]
  Key = kbdus[ScanCode]; /*Use our kbdus array which i copied from a website since i seriously don't want to make an gigantic array */
      ^


CODE:
Code:
#define _GNU_SOURCE
#include "stdio.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
int ScanCode;
int **Key;
/* KBDUS means US Keyboard Layout. This is a scancode table
*  used to layout a standard US keyboard. I have left some
*  comments in to give you an idea of what key is what, even
*  though I set it's array index to 0. You can change that to
*  whatever you want using a macro, if you wish! */
unsigned char kbdus[128] =
{
    0,  27, '1', '2', '3', '4', '5', '6', '7', '8',   /* 9 */
  '9', '0', '-', '=', 0,   /* Backspace */
  '\t',         /* Tab */
  'q', 'w', 'e', 'r',   /* 19 */
  't', 'y', 'u', 'i', 'o', 'p', '[', ']', 0,   /* Enter key */
    0,         /* 29   - Control */
  'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',   /* 39 */
'\'', '`',   0,      /* Left shift */
'\\', 'z', 'x', 'c', 'v', 'b', 'n',         /* 49 */
  'm', ',', '.', '/',   0,            /* Right shift */
  '*',
    0,   /* Alt */
  ' ',   /* Space bar */
    0,   /* Caps lock */
    0,   /* 59 - F1 key ... > */
    0,   0,   0,   0,   0,   0,   0,   0,
    0,   /* < ... F10 */
    0,   /* 69 - Num lock*/
    0,   /* Scroll Lock */
    0,   /* Home key */
    0,   /* Up Arrow */
    0,   /* Page Up */
  '-',
    0,   /* Left Arrow */
    0,
    0,   /* Right Arrow */
  '+',
    0,   /* 79 - End key*/
    0,   /* Down Arrow */
    0,   /* Page Down */
    0,   /* Insert Key */
    0,   /* Delete Key */
    0,   0,   0,
    0,   /* F11 Key */
    0,   /* F12 Key */
    0,   /* All other keys are undefined */
};
int scancoderec() {
   __asm__ volatile( "movl $0, %eax" ); /* Moving 00 to EAX. */
   __asm__ volatile( "int $0x16 "); /*int 0x16 */
   register int ValEAX asm("eax"); /* Let's get eax */
   ScanCode[strlen(ValEAX)-8] = '\0'; /* Remove last 8 bits from the value we gathered from EAX to get AH and make that the scancode. */
}

int keyrec() { /*This could be used as a keyboard driver. */
   scancoderec(); /*Get our scancode! */
   Key = kbdus[ScanCode]; /*Use our kbdus array which i copied from a website since i seriously don't want to make an gigantic array */
}

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group