Kernel/vfs - Fixed edge case bug with chroots
[tpg/acess2.git] / AcessNative / acesskernel_src / keyboard.c
1 /*
2  * Acess2 Native Kernel
3  * 
4  * Keyboard Driver
5  */
6 #include <acess.h>
7 #include <modules.h>
8 #include <fs_devfs.h>
9 #include <api_drv_keyboard.h>
10 #include "ui.h"
11
12 // === PROTOTYPES ===
13  int    NativeKeyboard_Install(char **Arguments);
14  int    NativeKeyboard_IOCtl(tVFS_Node *Node, int Id, void *Data);
15
16 // === GLOBALS ===
17 MODULE_DEFINE(0, 0x0100, NativeKeyboard, NativeKeyboard_Install, NULL, NULL);
18 tVFS_NodeType   gKB_NodeType = {
19         .IOCtl = NativeKeyboard_IOCtl
20 };
21 tDevFS_Driver   gKB_DevInfo = {
22         NULL, "NativeKeyboard",
23         { .Type = &gKB_NodeType }
24 };
25
26 // === CODE ===
27 /**
28  * \brief Install the keyboard driver
29  */
30 int NativeKeyboard_Install(char **Arguments)
31 {
32         DevFS_AddDevice( &gKB_DevInfo );
33         return MODULE_ERR_OK;
34 }
35
36 static const char * csaIOCTL_NAMES[] = {
37         DRV_IOCTLNAMES,
38         DRV_KEYBAORD_IOCTLNAMES,
39         NULL
40 };
41
42 /**
43  * \fn int KB_IOCtl(tVFS_Node *Node, int Id, void *Data)
44  * \brief Calls an IOCtl Command
45  */
46 int NativeKeyboard_IOCtl(tVFS_Node *Node, int Id, void *Data)
47 {
48         switch(Id)
49         {
50         BASE_IOCTLS(DRV_TYPE_KEYBOARD, "NativeKeyboard", 0x10000, csaIOCTL_NAMES);
51
52         // Sets the Keyboard Callback
53         case KB_IOCTL_SETCALLBACK:
54                 // Sanity Check
55                 if(Threads_GetUID() != 0)
56                         return 0;
57                 // Can only be set once
58                 if(gUI_KeyboardCallback != NULL)        return 0;
59                 // Set Callback
60                 gUI_KeyboardCallback = Data;
61                 return 1;
62
63         default:
64                 return 0;
65         }
66 }

UCC git Repository :: git.ucc.asn.au