Restructured and rewritten entire codebase

This commit is contained in:
Alex
2023-10-09 01:16:24 +03:00
parent 446a571018
commit 889e1522a3
484 changed files with 15683 additions and 14032 deletions

View File

@ -1,18 +1,18 @@
/*
This file is part of Fennix Kernel.
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_EXT2_H__
@ -22,7 +22,7 @@
#include <filesystem.hpp>
namespace VirtualFileSystem
namespace vfs
{
class EXT2
{

View File

@ -1,18 +1,18 @@
/*
This file is part of Fennix Kernel.
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_FAT_H__
@ -22,7 +22,7 @@
#include <filesystem.hpp>
namespace VirtualFileSystem
namespace vfs
{
class FAT
{
@ -40,7 +40,7 @@ namespace VirtualFileSystem
{
/** @brief The first three bytes EB 3C 90 disassemble to JMP SHORT 3C NOP. (The 3C value may be different.) The reason for this is to jump over the disk format information (the BPB and EBPB). Since the first sector of the disk is loaded into ram at location 0x0000:0x7c00 and executed, without this jump, the processor would attempt to execute data that isn't code. Even for non-bootable volumes, code matching this pattern (or using the E9 jump opcode) is required to be present by both Windows and OS X. To fulfil this requirement, an infinite loop can be placed here with the bytes EB FE 90. */
uint8_t JumpBoot[3];
/** @brief OEM identifier. The first 8 Bytes (3 - 10) is the version of DOS being used. The next eight Bytes 29 3A 63 7E 2D 49 48 and 43 read out the name of the version. The official FAT Specification from Microsoft says that this field is really meaningless and is ignored by MS FAT Drivers, however it does recommend the value "MSWIN4.1" as some 3rd party drivers supposedly check it and expect it to have that value. Older versions of dos also report MSDOS5.1, linux-formatted floppy will likely to carry "mkdosfs" here, and FreeDOS formatted disks have been observed to have "FRDOS5.1" here. If the string is less than 8 bytes, it is padded with spaces. */
/** @brief OEM identifier. The first 8 Bytes (3 - 10) is the version of DOS being used. The next eight Bytes 29 3A 63 7E 2D 49 48 and 43 read out the name of the version. The official FAT Specification from Microsoft says that this field is really meaningless and is ignored by MS FAT Modules, however it does recommend the value "MSWIN4.1" as some 3rd party drivers supposedly check it and expect it to have that value. Older versions of dos also report MSDOS5.1, linux-formatted floppy will likely to carry "mkdosfs" here, and FreeDOS formatted disks have been observed to have "FRDOS5.1" here. If the string is less than 8 bytes, it is padded with spaces. */
uint8_t OEM[8];
/** @brief The number of Bytes per sector (remember, all numbers are in the little-endian format). */
uint16_t BytesPerSector;

View File

@ -1,18 +1,18 @@
/*
This file is part of Fennix Kernel.
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_INITRD_H__
@ -22,7 +22,7 @@
#include <filesystem.hpp>
namespace VirtualFileSystem
namespace vfs
{
class Initrd
{

View File

@ -0,0 +1,32 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_IOCTL_H__
#define __FENNIX_KERNEL_FILESYSTEM_IOCTL_H__
#include <types.h>
#include <stropts.h>
struct winsize
{
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel;
unsigned short ws_ypixel;
};
#endif // !__FENNIX_KERNEL_FILESYSTEM_IOCTL_H__

View File

@ -1,18 +1,18 @@
/*
This file is part of Fennix Kernel.
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_DEV_H__
@ -22,9 +22,86 @@
#include <filesystem.hpp>
void Init_Null(VirtualFileSystem::Virtual *vfs_ctx);
void Init_Random(VirtualFileSystem::Virtual *vfs_ctx);
void Init_Teletype(VirtualFileSystem::Virtual *vfs_ctx);
void Init_Zero(VirtualFileSystem::Virtual *vfs_ctx);
namespace vfs
{
class vfsRoot : public Node
{
public:
vfsRoot(const char *Name, Virtual *vfs_ctx);
~vfsRoot() {}
};
class NullDevice : public Node
{
public:
virtual size_t read(uint8_t *Buffer,
size_t Size,
off_t Offset);
virtual size_t write(uint8_t *Buffer,
size_t Size,
off_t Offset);
NullDevice();
~NullDevice();
};
class RandomDevice : public Node
{
public:
virtual size_t read(uint8_t *Buffer,
size_t Size,
off_t Offset);
virtual size_t write(uint8_t *Buffer,
size_t Size,
off_t Offset);
RandomDevice();
~RandomDevice();
};
class ZeroDevice : public Node
{
public:
virtual size_t read(uint8_t *Buffer,
size_t Size,
off_t Offset);
virtual size_t write(uint8_t *Buffer,
size_t Size,
off_t Offset);
ZeroDevice();
~ZeroDevice();
};
class TTYDevice : public Node
{
public:
virtual size_t write(uint8_t *Buffer,
size_t Size,
off_t Offset);
virtual int ioctl(unsigned long Request,
void *Argp);
TTYDevice();
~TTYDevice();
};
class PTMXDevice : public Node
{
private:
Node *pts = nullptr;
public:
virtual size_t read(uint8_t *Buffer,
size_t Size,
off_t Offset);
virtual size_t write(uint8_t *Buffer,
size_t Size,
off_t Offset);
PTMXDevice();
~PTMXDevice();
};
}
#endif // !__FENNIX_KERNEL_FILESYSTEM_DEV_H__

View File

@ -1,18 +1,18 @@
/*
This file is part of Fennix Kernel.
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_FILESYSTEM_USTAR_H__
@ -22,69 +22,88 @@
#include <filesystem.hpp>
namespace VirtualFileSystem
namespace vfs
{
class USTAR
{
enum FileType
{
REGULAR_FILE = '0',
HARDLINK = '1',
SYMLINK = '2',
CHARDEV = '3',
BLOCKDEV = '4',
DIRECTORY = '5',
FIFO = '6'
};
class USTARNode : public Node
{
private:
uintptr_t Address;
struct FileHeader
{
char name[100];
char mode[8];
char uid[8];
char gid[8];
char size[12];
char mtime[12];
char chksum[8];
char typeflag[1];
char link[100];
char signature[6];
char version[2];
char owner[32];
char group[32];
char dev_maj[8];
char dev_min[8];
char prefix[155];
char pad[12];
};
public:
size_t read(uint8_t *Buffer,
size_t Size,
off_t Offset);
private:
uint32_t getsize(const char *s)
{
uint32_t ret = 0;
while (*s)
{
ret *= 8;
ret += *s - '0';
s++;
}
return ret;
}
USTARNode(uintptr_t Address,
const char *Name,
NodeType Type,
Virtual *vfs_ctx);
int string2int(const char *str)
{
int res = 0;
for (int i = 0; str[i] != '\0'; ++i)
res = res * 10 + str[i] - '0';
return res;
}
~USTARNode();
};
public:
bool TestArchive(uintptr_t Address);
void ReadArchive(uintptr_t Address, Virtual *vfs_ctx);
USTAR();
~USTAR();
};
class USTAR
{
enum FileType
{
REGULAR_FILE = '0',
HARDLINK = '1',
SYMLINK = '2',
CHARDEV = '3',
BLOCKDEV = '4',
DIRECTORY = '5',
FIFO = '6'
};
struct FileHeader
{
char name[100];
char mode[8];
char uid[8];
char gid[8];
char size[12];
char mtime[12];
char chksum[8];
char typeflag[1];
char link[100];
char signature[6];
char version[2];
char owner[32];
char group[32];
char dev_maj[8];
char dev_min[8];
char prefix[155];
char pad[12];
};
private:
uint32_t getsize(const char *s)
{
uint32_t ret = 0;
while (*s)
{
ret *= 8;
ret += *s - '0';
s++;
}
return ret;
}
int string2int(const char *str)
{
int res = 0;
for (int i = 0; str[i] != '\0'; ++i)
res = res * 10 + str[i] - '0';
return res;
}
public:
bool TestArchive(uintptr_t Address);
void ReadArchive(uintptr_t Address, Virtual *vfs_ctx);
USTAR();
~USTAR();
};
}
#endif // !__FENNIX_KERNEL_FILESYSTEM_USTAR_H__