Compare commits
No commits in common. "61f1852420f06e840d3cb7f0c40fcaae83d118a1" and "745656eb2d8b512b195d2db0be7ee73a82562b43" have entirely different histories.
61f1852420
...
745656eb2d
@ -5,7 +5,7 @@ BUILD_DIR = ../build/CoreLib
|
|||||||
OBJ_FOLDER = ../bin/CoreLib
|
OBJ_FOLDER = ../bin/CoreLib
|
||||||
OUTPUTFILE = $(BUILD_DIR)/libCoreLib.a
|
OUTPUTFILE = $(BUILD_DIR)/libCoreLib.a
|
||||||
|
|
||||||
OFILES = $(OBJ_FOLDER)/ctype.o $(OBJ_FOLDER)/memory.o $(OBJ_FOLDER)/path.o $(OBJ_FOLDER)/stack.o $(OBJ_FOLDER)/string.o $(OBJ_FOLDER)/stringview.o
|
OFILES = $(OBJ_FOLDER)/memory.o $(OBJ_FOLDER)/path.o $(OBJ_FOLDER)/stack.o $(OBJ_FOLDER)/string.o $(OBJ_FOLDER)/stringview.o
|
||||||
|
|
||||||
.phony: all
|
.phony: all
|
||||||
all: $(OUTPUTFILE)
|
all: $(OUTPUTFILE)
|
||||||
@ -15,11 +15,6 @@ $(OUTPUTFILE): $(OFILES)
|
|||||||
pwd
|
pwd
|
||||||
ar -rc $(OUTPUTFILE) $(OFILES)
|
ar -rc $(OUTPUTFILE) $(OFILES)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(OBJ_FOLDER)/ctype.o: ctype.cpp
|
|
||||||
$(CPP) -c ctype.cpp -o $(OBJ_FOLDER)/ctype.o $(CFLAGS)
|
|
||||||
|
|
||||||
$(OBJ_FOLDER)/memory.o: Memory.cpp
|
$(OBJ_FOLDER)/memory.o: Memory.cpp
|
||||||
$(CPP) -c Memory.cpp -o $(OBJ_FOLDER)/memory.o $(CFLAGS)
|
$(CPP) -c Memory.cpp -o $(OBJ_FOLDER)/memory.o $(CFLAGS)
|
||||||
|
|
||||||
|
@ -1,141 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by nigel on 25/02/23.
|
|
||||||
//
|
|
||||||
#include "ctype.h"
|
|
||||||
|
|
||||||
int isupper (int ch){
|
|
||||||
if( ch >= 'A' && ch <= 'Z'){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int islower (int ch){
|
|
||||||
if(ch >= 'a' && ch <= 'z'){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isalpha (int ch) {
|
|
||||||
if(isupper(ch)){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(islower(ch)){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int isdigit (int ch){
|
|
||||||
if(ch >= '0' && ch <= '9'){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isxdigit (int ch){
|
|
||||||
if(isdigit(ch)){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ch >= 'a' && ch <= 'f'){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ch >= 'A' && ch <= 'F'){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iscntrl (int ch){
|
|
||||||
if(ch >= 0x00 && ch <= 0x1f )
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x7f)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int isgraph (int ch){
|
|
||||||
if(isdigit(ch))
|
|
||||||
return 1;
|
|
||||||
if(isupper(ch))
|
|
||||||
return 1;
|
|
||||||
if(islower(ch))
|
|
||||||
return 1;
|
|
||||||
if(ispunct(ch))
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isspace(int ch){
|
|
||||||
if (ch == 0x20)
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x0c)
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x0a)
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x0d)
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x09)
|
|
||||||
return 1;
|
|
||||||
if(ch == 0x0b)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isblank (int ch){
|
|
||||||
if( ch == 0x20 || ch == 0x09)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ispunct(int ch){
|
|
||||||
if(ch >= '!' && ch <= '~')
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isprint (int ch){
|
|
||||||
if (isdigit(ch))
|
|
||||||
return 1;
|
|
||||||
if(isupper(ch))
|
|
||||||
return 1;
|
|
||||||
if(islower(ch))
|
|
||||||
return 1;
|
|
||||||
if(ispunct(ch))
|
|
||||||
return 1;
|
|
||||||
if(isspace(ch))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int tolower(int ch){
|
|
||||||
|
|
||||||
if(islower(ch)) return ch;
|
|
||||||
int diff = 'a' - 'A';
|
|
||||||
return ch + diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
int toupper(int ch){
|
|
||||||
if(isupper(ch)) return ch;
|
|
||||||
int diff = 'a' - 'A';
|
|
||||||
return ch - diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int isalnum (int ch){
|
|
||||||
if(isdigit(ch)){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isalpha(ch)){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by nigel on 25/02/23.
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
//NOTE: Uses default locale
|
|
||||||
int isupper (int ch);
|
|
||||||
int islower (int ch);
|
|
||||||
int isalpha (int ch);
|
|
||||||
int isdigit (int ch);
|
|
||||||
int isxdigit (int ch);
|
|
||||||
int iscntrl (int ch);
|
|
||||||
int isgraph(int ch);
|
|
||||||
int isspace(int ch);
|
|
||||||
int isblank(int ch);
|
|
||||||
int ispunct(int ch);
|
|
||||||
int isprint(int ch);
|
|
||||||
int isalnum (int ch);
|
|
||||||
int tolower(int ch);
|
|
||||||
int toupper(int ch);
|
|
||||||
|
|
@ -122,8 +122,6 @@ extern "C" void kernel ()
|
|||||||
printf(" [Size: %d bytes, Attributes: %d]\n", entry->ATTR, entry->FileSize);
|
printf(" [Size: %d bytes, Attributes: %d]\n", entry->ATTR, entry->FileSize);
|
||||||
if(entry->ATTR & FAT::ATTRIBUTES::ATTR_DIRECTORY ){
|
if(entry->ATTR & FAT::ATTRIBUTES::ATTR_DIRECTORY ){
|
||||||
FAT::OpenSubdir(entry, bpb);
|
FAT::OpenSubdir(entry, bpb);
|
||||||
} else {
|
|
||||||
FAT::readFile(entry, bpb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,8 @@ uint16_t FAT::GetFATEntry (BiosParameterBlock* bpb, unsigned int cluster){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t FAT::DetermineFreeSpace()
|
uint16_t FAT::DetermineFreeSpace()
|
||||||
{
|
{
|
||||||
// Loop through all FAT entries in all FAT's
|
// Loop through all FAT entries in all FAT's
|
||||||
@ -178,6 +180,8 @@ unsigned int FAT::RootDirSize(BiosParameterBlock* bpb)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t* ReadFAT (BiosParameterBlock& bpb , bool DEBUG = false ) {
|
uint16_t* ReadFAT (BiosParameterBlock& bpb , bool DEBUG = false ) {
|
||||||
uint32_t FATAddress = /*StartAddress*/ 0x00 + bpb.RsvdSecCnt ;
|
uint32_t FATAddress = /*StartAddress*/ 0x00 + bpb.RsvdSecCnt ;
|
||||||
uint16_t* FAT = (uint16_t*)malloc(sizeof (uint16_t) * 256);
|
uint16_t* FAT = (uint16_t*)malloc(sizeof (uint16_t) * 256);
|
||||||
@ -249,29 +253,42 @@ void FAT::OpenSubdir(DIR* directory, BiosParameterBlock* bpb ){
|
|||||||
printf("LFN\n");
|
printf("LFN\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FAT::readFile(DIR* fileEntry , BiosParameterBlock* bpb){
|
|
||||||
unsigned int cluster = fileEntry->FstClusLo;
|
|
||||||
unsigned int FATEntry = FAT::GetFATEntry(bpb, cluster);
|
|
||||||
unsigned int root_dir_sectors = FAT::RootDirSize(bpb);
|
|
||||||
unsigned int fat_size = bpb->FATSz16;
|
|
||||||
unsigned int first_data_sector = bpb->RsvdSecCnt + (bpb->NumFATs * fat_size) + root_dir_sectors;
|
|
||||||
unsigned int file_data_sector = ((cluster -2) * bpb->SecPerClus) + first_data_sector;
|
|
||||||
printf("FAT entry = %x\n", FATEntry);
|
|
||||||
uint16_t data[256];
|
|
||||||
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, file_data_sector, data);
|
|
||||||
|
|
||||||
for (unsigned short n : data)
|
void readFile(uint32_t DataRegion, DIR* entry, uint16_t FATentry, BiosParameterBlock& bpb ){
|
||||||
{
|
printf("Show contents");
|
||||||
|
|
||||||
|
printf("Start cluster of the file: 0x%x\n", entry->FileSize);
|
||||||
|
|
||||||
|
printf("IS it only 1 cluster? %s\n", FATentry == 0xFFFF ? "Yes" : "No");
|
||||||
|
|
||||||
|
uint32_t sector = DataRegion + ((entry->FileSize - 0x02) * bpb.SecPerClus);
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t dataBlob[256];
|
||||||
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, sector, dataBlob);
|
||||||
|
for (unsigned short n: dataBlob) {
|
||||||
kterm_put(n & 0x00ff);
|
kterm_put(n & 0x00ff);
|
||||||
|
|
||||||
kterm_put(n >> 8);
|
kterm_put(n >> 8);
|
||||||
}
|
}
|
||||||
|
kterm_put('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
file fsysFatDirectory (const char* DirectoryName){
|
file fsysFatDirectory (const char* DirectoryName){
|
||||||
file file;
|
file file;
|
||||||
|
@ -83,7 +83,6 @@ public:
|
|||||||
static int GetSectorOfRootDirectory(BiosParameterBlock*);
|
static int GetSectorOfRootDirectory(BiosParameterBlock*);
|
||||||
static unsigned int RootDirSize(BiosParameterBlock*);
|
static unsigned int RootDirSize(BiosParameterBlock*);
|
||||||
static void OpenSubdir (DIR*, BiosParameterBlock*);
|
static void OpenSubdir (DIR*, BiosParameterBlock*);
|
||||||
static void readFile(DIR*, BiosParameterBlock*);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user