3 * - By John Hodge (thePowersGang)
6 * - /Devices/{null,zero,one}
14 int CoreDevs_Install(char **Arguments);
15 size_t CoreDevs_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer);
16 size_t CoreDevs_Read_Zero(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
17 size_t CoreDevs_Read_One (tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
18 size_t CoreDevs_Read_Null(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
19 size_t CoreDevs_Read_FRandom(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
20 size_t CoreDevs_Read_GRandom(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer);
23 MODULE_DEFINE(0, 0x0100, CoreDevs, CoreDevs_Install, NULL, NULL);
24 tVFS_NodeType gCoreDevs_NT_Null = {
25 .TypeName = "CoreDevs-null",
26 .Read = CoreDevs_Read_Null,
27 .Write = CoreDevs_Write
29 tVFS_NodeType gCoreDevs_NT_Zero = {
30 .TypeName = "CoreDevs-zero",
31 .Read = CoreDevs_Read_Zero,
32 .Write = CoreDevs_Write
34 tVFS_NodeType gCoreDevs_NT_One = {
35 .TypeName = "CoreDevs-one",
36 .Read = CoreDevs_Read_One,
37 .Write = CoreDevs_Write
39 tVFS_NodeType gCoreDevs_NT_FRandom = {
40 .TypeName = "CoreDevs-frandom",
41 .Read = CoreDevs_Read_FRandom,
42 .Write = CoreDevs_Write
44 tVFS_NodeType gCoreDevs_NT_GRandom = {
45 .TypeName = "CoreDevs-grandom",
46 .Read = CoreDevs_Read_GRandom,
47 .Write = CoreDevs_Write
49 tDevFS_Driver gCoreDevs_Null = {
52 .Size = 0, .NumACLs = 1,
53 .ACLs = &gVFS_ACL_EveryoneRW,
54 .Type = &gCoreDevs_NT_Null
57 tDevFS_Driver gCoreDevs_Zero = {
60 .Size = 0, .NumACLs = 1,
61 .ACLs = &gVFS_ACL_EveryoneRW,
62 .Type = &gCoreDevs_NT_Zero
65 tDevFS_Driver gCoreDevs_One = {
68 .Size = 0, .NumACLs = 1,
69 .ACLs = &gVFS_ACL_EveryoneRW,
70 .Type = &gCoreDevs_NT_One
73 tDevFS_Driver gCoreDevs_FRandom = {
76 .Size = 0, .NumACLs = 1,
77 .ACLs = &gVFS_ACL_EveryoneRW,
78 .Type = &gCoreDevs_NT_FRandom
81 tDevFS_Driver gCoreDevs_GRandom = {
84 .Size = 0, .NumACLs = 1,
85 .ACLs = &gVFS_ACL_EveryoneRW,
86 .Type = &gCoreDevs_NT_GRandom
92 * \brief Installs the CoreDevs driver
94 int CoreDevs_Install(char **Options)
96 DevFS_AddDevice( &gCoreDevs_Null );
97 DevFS_AddDevice( &gCoreDevs_Zero );
98 DevFS_AddDevice( &gCoreDevs_One );
99 DevFS_AddDevice( &gCoreDevs_FRandom );
100 //DevFS_AddDevice( &gCoreDevs_GRandom );
101 return MODULE_ERR_OK;
104 size_t CoreDevs_Write(tVFS_Node *Node, off_t Offset, size_t Length, const void *Buffer)
106 return Length; // Ignore
109 size_t CoreDevs_Read_Zero(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
111 memset(Buffer, 0, Length);
115 size_t CoreDevs_Read_One (tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
119 for( rem = Length; rem --; ptr ++ )
124 size_t CoreDevs_Read_Null(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
129 //! Fast random number generator
130 size_t CoreDevs_Read_FRandom(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
132 Uint8 *cbuf = Buffer;
133 for( int i = 0; i < Length; i ++ )
138 size_t CoreDevs_Read_GRandom(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
140 Log_Error("CoreDevs", "GRandom is unimplimented");