Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 59 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1dc2c26
Setting up GitHub Classroom Feedback
github-classroom[bot] Feb 14, 2023
1af43d6
Update README.md
NerbFox Feb 18, 2023
8064989
add linker
Feb 18, 2023
ef9ad57
3.7
Feb 18, 2023
f64e2b0
add gdt entry attributes
Feb 18, 2023
286c149
dummy
Feb 18, 2023
fe28a26
semoga bnr
Feb 18, 2023
f1347b4
update position
NerbFox Feb 18, 2023
ed44b69
enter protected mode
Feb 18, 2023
580432b
Merge branch 'main' of https://github.com/Sister20/if2230-2023-osyikkk
NerbFox Feb 18, 2023
025955c
replace cursor and memory framebuffer with macro
Feb 21, 2023
bf9eece
Update milestone 2
NerbFox Mar 19, 2023
2a334a8
implement idt, interrupt, and organizing repo files
Mar 19, 2023
b9738ec
Add keyboard implementation
Mar 19, 2023
aa8f85f
update hanif
RMA1403 Mar 27, 2023
3d2a7db
Update FAT32
Mar 27, 2023
6a4d34a
fix makefile
razzanYoni Mar 27, 2023
6d88189
fix : makefile
razzanYoni Mar 27, 2023
f9ed853
balikin disk ke uint_16
razzanYoni Mar 27, 2023
164a2f7
fix : biar bisa ke-load
razzanYoni Mar 28, 2023
c0cf831
Update read and read_directory implementation
Mar 28, 2023
1f3aecd
update CRUD
Mar 29, 2023
7b9c010
Update README.md
razzanYoni Mar 29, 2023
2e02feb
Update README.md
razzanYoni Mar 29, 2023
9bccff1
CRUD finished
Mar 29, 2023
1814c4a
Merge branch 'main' of github.com:Sister20/if2230-2023-osyikkk into main
Mar 29, 2023
98f898c
update cmos, todo
Mar 29, 2023
457db49
update makefile
Mar 29, 2023
44953f0
Update cmos (not yet finished)
Mar 30, 2023
6ba6645
Fix scrolling keyboard, delete todo
Mar 30, 2023
011a52d
Update Milestone 3
NerbFox Apr 3, 2023
21d00e7
Create kernel_loader.s
NerbFox Apr 3, 2023
2ea4415
Update 3.1 and 3.2
Apr 3, 2023
7bb8c31
implement 3.2
razzanYoni Apr 21, 2023
f896c73
fix: 3.1 alhamdulillah aman
Apr 21, 2023
7d1fe63
feat: implement 3.2.1 (not finished)
Apr 23, 2023
700d192
fix: inserter 3.1
Apr 23, 2023
da1e433
feat: implement 3.2
Apr 26, 2023
433e90c
feat: implement 3.3.1
hanifmz07 Apr 26, 2023
47b7168
fix: comment puts (not yet implemented)
hanifmz07 Apr 26, 2023
c8b9fc2
feat: implement several common syscall
hanifmz07 Apr 27, 2023
c177381
Merge branch 'main' into fix/revert-3.2
razzanYoni Apr 27, 2023
2082648
Merge pull request #2 from Sister20/fix/revert-3.2
razzanYoni Apr 27, 2023
c33573e
feat: implement cd and ls (not finished)
hanifmz07 Apr 27, 2023
dab930e
feat: update mkdir, ls, rm, cp
hanifmz07 Apr 28, 2023
bdb2976
feat: update cat, rm, whereis
hanifmz07 Apr 28, 2023
5ab5e50
feat: update rm, whereis
hanifmz07 Apr 29, 2023
8d09deb
feat: whereis
RMA1403 Apr 29, 2023
48ce9dc
feat: update number of arguments validation
hanifmz07 Apr 29, 2023
96ef693
Merge branch 'main' into feat/whereis
RMA1403 Apr 29, 2023
56fc9de
Merge pull request #3 from Sister20/feat/whereis
RMA1403 Apr 29, 2023
bd50559
add gitignore
hanifmz07 Apr 29, 2023
cba923e
fix: duplicate command
hanifmz07 Apr 29, 2023
0f6cacf
feat: handle 2 path arguments
hanifmz07 Apr 29, 2023
a830957
feat: update mv
hanifmz07 Apr 29, 2023
53859ed
feat: finalize all commands :)
hanifmz07 Apr 29, 2023
7dd8a4b
bonus cp rekursif tapi telat 11 menit :(((((
RMA1403 Apr 29, 2023
5ce186c
update readme
NerbFox Apr 29, 2023
3bcde73
Merge branch 'main' of https://github.com/Sister20/if2230-2023-osyikkk
NerbFox Apr 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/test
*.json
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ Tugas IF2230 - Sistem Operasi 2023 Tahun 2022/2023


## General Information
G
Operating System


## Technologies Used
-
- Qemu
- NASM
- C

<!-- ## Penjelasan Singkat Algoritma
* -->


## Features
- Implementasi dari
- Implementasi dari mata kuliah Sistem Operasi

## Screenshots
![Example screenshot](./doc/OS.png)


## How to Run
-
- make run di terminal

## Project Status
Project is: _not complete_
Expand All @@ -45,11 +45,12 @@ Project is: _not complete_
## Room for Improvement

Room for improvement:
- speed
- speed up the code
- add more features


## Division of tasks
1. Nigel Sahl (13521043) :
2. Razzan Daksana Yoni (13521087) :
3. Rava Maulana Azzikri (13521149) :
4. Hanif Muhammad Zhafran (13521157) :
1. Nigel Sahl (13521043)
2. Razzan Daksana Yoni (13521087)
3. Rava Maulana Azzikri (13521149)
4. Hanif Muhammad Zhafran (13521157)
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ kernel:

@$(CC) $(CFLAGS) $(SOURCE_FOLDER)/$(INTERRUPT_FOLDER)/idt.c -o $(OUTPUT_FOLDER)/idt.o
@$(CC) $(CFLAGS) $(SOURCE_FOLDER)/$(INTERRUPT_FOLDER)/interrupt.c -o $(OUTPUT_FOLDER)/interrupt.o
@$(CC) $(CFLAGS) $(SOURCE_FOLDER)/$(KEYBOARD_FOLDER)/keyboard.c -o $(OUTPUT_FOLDER)/keyboard.o


@$(LIN) $(LFLAGS) bin/*.o -o $(OUTPUT_FOLDER)/kernel
Expand Down
52 changes: 52 additions & 0 deletions src/filesystem/disk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "../lib-header/disk.h"
#include "../lib-header/portio.h"

static void ATA_busy_wait() {
while (in(0x1F7) & ATA_STATUS_BSY);
}

static void ATA_DRQ_wait() {
while (!(in(0x1F7) & ATA_STATUS_RDY));
}

void read_blocks(void *ptr, uint32_t logical_block_address, uint8_t block_count) {
ATA_busy_wait();
out(0x1F6, 0xE0 | ((logical_block_address >> 24) & 0xF));
out(0x1F2, block_count);
out(0x1F3, (uint8_t) logical_block_address);
out(0x1F4, (uint8_t) (logical_block_address >> 8));
out(0x1F5, (uint8_t) (logical_block_address >> 16));
out(0x1F7, 0x20);

uint16_t *target = (uint16_t*) ptr;

for (uint32_t i = 0; i < block_count; i++) {
ATA_busy_wait();
ATA_DRQ_wait();
for (uint32_t j = 0; j < HALF_BLOCK_SIZE; j++)
target[j] = in16(0x1F0);
// Note : uint16_t => 2 bytes, HALF_BLOCK_SIZE*2 = BLOCK_SIZE with pointer arithmetic
target += HALF_BLOCK_SIZE;
}
}

void write_blocks(const void *ptr, uint32_t logical_block_address, uint8_t block_count) {
ATA_busy_wait();
out(0x1F6, 0xE0 | ((logical_block_address >> 24) & 0xF));
out(0x1F2, block_count);
out(0x1F3, (uint8_t) logical_block_address);
out(0x1F4, (uint8_t) (logical_block_address >> 8));
out(0x1F5, (uint8_t) (logical_block_address >> 16));
out(0x1F7, 0x30);

for (uint32_t i = 0; i < block_count; i++) {
ATA_busy_wait();
ATA_DRQ_wait();
/* Note : uint16_t => 2 bytes, i is current block number to write
HALF_BLOCK_SIZE*i = block_offset with pointer arithmetic
*/
for (uint32_t j = 0; j < HALF_BLOCK_SIZE; j++)
out16(0x1F0, ((uint16_t*) ptr)[HALF_BLOCK_SIZE*i + j]);
}
}

134 changes: 133 additions & 1 deletion src/filesystem/fat32.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,136 @@ const uint8_t fs_signature[BLOCK_SIZE] = {
'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2', '0', '2', '3', '\n',
[BLOCK_SIZE-2] = 'O',
[BLOCK_SIZE-1] = 'k',
};
};

/* -- Driver Interfaces -- */

/**
* Convert cluster number to logical block address
*
* @param cluster Cluster number to convert
* @return uint32_t Logical Block Address
*/
uint32_t cluster_to_lba(uint32_t cluster){
// dr nanobyte -> lba = data_region_begin + (cluster-2)*sector_per_cluster
return (cluster-2) * cluster_size; // ?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On extra sidenote: Untuk tugas besar ini lebih straightforward lagi Cluster to LBA-nya, no offset, no anything, cluster 0 berada di block 0, cluster 1 di block 4, and so on

}

/**
* Initialize DirectoryTable value with parent DirectoryEntry and directory name
*
* @param dir_table Pointer to directory table
* @param name 8-byte char for directory name
* @param parent_dir_cluster Parent directory cluster number
*/
void init_directory_table(struct FAT32DirectoryTable *dir_table, char *name, uint32_t parent_dir_cluster){

}

/**
* Checking whether filesystem signature is missing or not in boot sector
*
* @return True if memcmp(boot_sector, fs_signature) returning inequality
*/
bool is_empty_storage(void){

}

/**
* Create new FAT32 file system. Will write fs_signature into boot sector and
* proper FileAllocationTable (contain CLUSTER_0_VALUE, CLUSTER_1_VALUE,
* and initialized root directory) into cluster number 1
*/
void create_fat32(void){

}

/**
* Initialize file system driver state, if is_empty_storage() then create_fat32()
* Else, read and cache entire FileAllocationTable (located at cluster number 1) into driver state
*/
void initialize_filesystem_fat32(void){
if (is_empty_storage()){
create_fat32();
} else {
// read cluster 1
// cache FAT

}
}

/**
* Write cluster operation, wrapper for write_blocks().
* Recommended to use struct ClusterBuffer
*
* @param ptr Pointer to source data
* @param cluster_number Cluster number to write
* @param cluster_count Cluster count to write, due limitation of write_blocks block_count 255 => max cluster_count = 63
*/
void write_clusters(const void *ptr, uint32_t cluster_number, uint8_t cluster_count){

}

/**
* Read cluster operation, wrapper for read_blocks().
* Recommended to use struct ClusterBuffer
*
* @param ptr Pointer to buffer for reading
* @param cluster_number Cluster number to read
* @param cluster_count Cluster count to read, due limitation of read_blocks block_count 255 => max cluster_count = 63
*/
void read_clusters(void *ptr, uint32_t cluster_number, uint8_t cluster_count){

}





/* -- CRUD Operation -- */

/**
* FAT32 Folder / Directory read
*
* @param request buf point to struct FAT32DirectoryTable,
* name is directory name,
* ext is unused,
* parent_cluster_number is target directory table to read,
* buffer_size must be exactly sizeof(struct FAT32DirectoryTable)
* @return Error code: 0 success - 1 not a folder - 2 not found - -1 unknown
*/
int8_t read_directory(struct FAT32DriverRequest request){

}


/**
* FAT32 read, read a file from file system.
*
* @param request All attribute will be used for read, buffer_size will limit reading count
* @return Error code: 0 success - 1 not a file - 2 not enough buffer - 3 not found - -1 unknown
*/
int8_t read(struct FAT32DriverRequest request){

}

/**
* FAT32 write, write a file or folder to file system.
*
* @param request All attribute will be used for write, buffer_size == 0 then create a folder / directory
* @return Error code: 0 success - 1 file/folder already exist - 2 invalid parent cluster - -1 unknown
*/
int8_t write(struct FAT32DriverRequest request){

}


/**
* FAT32 delete, delete a file or empty directory (only 1 DirectoryEntry) in file system.
*
* @param request buf and buffer_size is unused
* @return Error code: 0 success - 1 not found - 2 folder is not empty - -1 unknown
*/
int8_t delete(struct FAT32DriverRequest request){

}
87 changes: 79 additions & 8 deletions src/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,47 @@
#include "lib-header/stdmem.h"
#include "lib-header/portio.h"


void framebuffer_set_cursor(uint8_t r, uint8_t c) {
// TODO : Implement
out(CURSOR_PORT_CMD, 0x0A);
out(CURSOR_PORT_DATA, (in(CURSOR_PORT_DATA) & 0xC0) | r);

out(CURSOR_PORT_CMD, 0x0B);
out(CURSOR_PORT_DATA, (in(CURSOR_PORT_DATA) & 0xE0) | c);
uint16_t pos = r * MAX_COLS + c;
// out(0x3D4, 0x0F);
// out(0x3D5, (uint8_t)(pos & 0xFF));
// out(0x3D4, 0x0E);
// out(0x3D5, (uint8_t)((pos >> 8) & 0xFF));

out(CURSOR_PORT_CMD, VGA_CURSOR_HIGH);
out(CURSOR_PORT_DATA, (uint8_t)((pos >> 8) & 0xFF));
out(CURSOR_PORT_CMD, VGA_CURSOR_LOW);
out(CURSOR_PORT_DATA, (uint8_t)(pos & 0xFF));
}

struct Cursor framebuffer_get_cursor() {
out(CURSOR_PORT_CMD, VGA_CURSOR_HIGH);
int offset = in(CURSOR_PORT_DATA) << 8;
out(CURSOR_PORT_CMD, VGA_CURSOR_LOW);
offset += in(CURSOR_PORT_DATA);
struct Cursor c =
{
.row = offset / MAX_COLS,
.col = offset % MAX_COLS
};
return c;
};

int framebuffer_get_col(struct Cursor c) {
return c.col;
}

int framebuffer_get_row(struct Cursor c) {
return c.row;
}

void framebuffer_write(uint8_t row, uint8_t col, char c, uint8_t fg, uint8_t bg) {
// TODO : Implement
uint16_t attrib = (bg << 4) | (fg & 0x0F);
uint16_t attrib = (bg << 4) | (fg & WHITE);
volatile uint16_t * where;
where = (volatile uint16_t *)MEMORY_FRAMEBUFFER + (row * 80 + col) ;
where = (volatile uint16_t *)MEMORY_FRAMEBUFFER + (row * MAX_COLS + col) ;
*where = c | (attrib << 8);
}

Expand All @@ -26,8 +53,52 @@ void framebuffer_clear(void) {
uint16_t i;
volatile uint16_t * where;
where = (volatile uint16_t *)MEMORY_FRAMEBUFFER;
for (i = 0; i < 80 * 25; i++) {
for (i = 0; i < MAX_COLS * MAX_ROWS; i++) {
*where = space;
where++;
}
}

void framebuffer_write_string(char * str) {
struct Cursor c = framebuffer_get_cursor();
int offset = c.row * MAX_COLS + c.col;
int i = 0;
while (str[i] != '\0') {
if (offset >= MAX_COLS * MAX_ROWS) {
offset = framebuffer_scroll_ln(offset);
}
if (str[i] == '\n') {
// offset = (offset / 160 + 1) * 160;
offset = (offset / MAX_COLS + 1) * MAX_COLS;
} else {
// framebuffer_write(offset / 160, offset % 160, str[i], WHITE, BLACK);
framebuffer_write(offset / MAX_COLS, offset % MAX_COLS, str[i], WHITE, BLACK);
offset += 1;
}
i++;
}
framebuffer_set_cursor(offset / MAX_COLS, offset % MAX_COLS);
}

int framebuffer_scroll_ln(int offset) {
// di enter dulu baru scroll
memcpy(
(void *)MEMORY_FRAMEBUFFER,
(void *)(MEMORY_FRAMEBUFFER + MAX_COLS * 2),
// (void *)(MEMORY_FRAMEBUFFER + MAX_COLS * 2),
// 160 * 2 * 24);
// 2 * MAX_COLS * 2 * (MAX_ROWS - 1));
MAX_COLS * 2 * (MAX_ROWS + 1));

for (int i = 0; i < MAX_COLS; i++) {
framebuffer_write(MAX_ROWS - 1, i, ' ', WHITE, BLACK);
framebuffer_write(MAX_ROWS - 2, i, ' ', WHITE, BLACK);
// framebuffer_write(MAX_ROWS - 3, i, ' ', WHITE, BLACK);
}


// return (c.row * MAX_COLS + c.col) - (MAX_ROWS - 1) * MAX_COLS;
// return (c.row * MAX_COLS + c.col) - 2 * MAX_COLS;
return (offset) - 3 * (MAX_COLS);
// return offset - (MAX_ROWS - 1) * MAX_COLS;
}
2 changes: 1 addition & 1 deletion src/interrupt/idt.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../lib-header/idt.h"

void *isr_stub_table[ISR_STUB_TABLE_LIMIT];
// void *isr_stub_table[ISR_STUB_TABLE_LIMIT];
struct IDTR _idt_idtr;

// global initialization of IDT
Expand Down
Loading