Remove unused code to make code smaller
These might need to be added back eventually.
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <conio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "filesystem/fat.h"
|
|
||||||
#include "filesystem/o65.h"
|
|
||||||
|
|
||||||
void exec(char* filename) {
|
|
||||||
o65_header_t* header;
|
|
||||||
o65_opt_t* o65_opt;
|
|
||||||
uint8_t* seg_ptr;
|
|
||||||
|
|
||||||
uint8_t* code_base;
|
|
||||||
uint8_t* data_base;
|
|
||||||
uint16_t code_len;
|
|
||||||
uint16_t data_len;
|
|
||||||
|
|
||||||
uint8_t (*exec)(void);
|
|
||||||
uint8_t ret;
|
|
||||||
|
|
||||||
fat_read(filename, fat_buf);
|
|
||||||
|
|
||||||
header = (o65_header_t*)fat_buf;
|
|
||||||
|
|
||||||
if (header->c64_marker == O65_NON_C64 &&
|
|
||||||
header->magic[0] == O65_MAGIC_0 &&
|
|
||||||
header->magic[1] == O65_MAGIC_1 &&
|
|
||||||
header->magic[2] == O65_MAGIC_2) {
|
|
||||||
|
|
||||||
code_base = (uint8_t*)header->tbase;
|
|
||||||
data_base = (uint8_t*)header->dbase;
|
|
||||||
code_len = header->tlen;
|
|
||||||
data_len = header->dlen;
|
|
||||||
|
|
||||||
|
|
||||||
o65_opt = (o65_opt_t*)(fat_buf + sizeof(o65_header_t));
|
|
||||||
while (o65_opt->olen)
|
|
||||||
{
|
|
||||||
o65_print_option(o65_opt);
|
|
||||||
o65_opt = (o65_opt_t*)((uint8_t*)o65_opt + o65_opt->olen);
|
|
||||||
}
|
|
||||||
|
|
||||||
seg_ptr = (uint8_t*)o65_opt + 1;
|
|
||||||
|
|
||||||
memcpy((uint8_t*)code_base, seg_ptr, code_len);
|
|
||||||
|
|
||||||
seg_ptr+=code_len;
|
|
||||||
|
|
||||||
memcpy((uint8_t*)data_base, seg_ptr, data_len);
|
|
||||||
|
|
||||||
exec = (uint8_t (*)(void))code_base;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
ret = (*exec)();
|
|
||||||
|
|
||||||
cprintf("ret: %x\n", ret);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef _EXEC_H
|
|
||||||
#define _EXEC_H
|
|
||||||
|
|
||||||
void exec(char* filename);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -13,37 +13,6 @@ static full_bpb_t bpb;
|
|||||||
|
|
||||||
static uint32_t data_region_start;
|
static uint32_t data_region_start;
|
||||||
|
|
||||||
void fat_print_pbp_info(full_bpb_t* bpb){
|
|
||||||
cprintf("Bytes per sector: %d\n", bpb->bytes_per_sector);
|
|
||||||
cprintf("Sectors per cluster: %d\n", bpb->sectors_per_cluster);
|
|
||||||
cprintf("Reserved Sectors: %d\n", bpb->reserved_sectors);
|
|
||||||
cprintf("Fat Count: %d\n", bpb->fat_count);
|
|
||||||
cprintf("Max Dir Entries: %d\n", bpb->max_dir_entries);
|
|
||||||
cprintf("Total Sector Count: %d\n", bpb->total_sector_count);
|
|
||||||
cprintf("Media Descriptor: 0x%x\n", bpb->media_descriptor);
|
|
||||||
cprintf("Sectors per Fat: %d\n", bpb->sectors_per_fat_16);
|
|
||||||
cprintf("\n");
|
|
||||||
|
|
||||||
cprintf("Sectors per track: %d\n", bpb->sectors_per_track);
|
|
||||||
cprintf("Head Count: %d\n", bpb->head_count);
|
|
||||||
cprintf("Hidden Sector Count: %ld\n", bpb->hidden_sector_count);
|
|
||||||
cprintf("Logical Sector Count: %ld\n", bpb->logical_sector_count);
|
|
||||||
cprintf("Sectors per Fat: %ld\n", bpb->sectors_per_fat_32);
|
|
||||||
cprintf("Extended Flags: 0x%x\n", bpb->extended_flags);
|
|
||||||
cprintf("Version: %d\n", bpb->version);
|
|
||||||
cprintf("Root Cluster: 0x%lx\n", bpb->root_cluster);
|
|
||||||
cprintf("System Information: 0x%x\n", bpb->system_information);
|
|
||||||
cprintf("Backup Boot Sector: 0x%x\n", bpb->backup_boot_sector);
|
|
||||||
cprintf("\n");
|
|
||||||
|
|
||||||
cprintf("Drive Number: %d\n", bpb->drive_num);
|
|
||||||
cprintf("Extended Signature: 0x%x\n", bpb->extended_signature);
|
|
||||||
cprintf("Volume ID: 0x%lx\n", bpb->volume_id);
|
|
||||||
cprintf("Partition Label: %.11s\n", &bpb->partition_label);
|
|
||||||
cprintf("Partition Label: %.8s\n", &bpb->filesystem_type);
|
|
||||||
cprintf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void fat_init(){
|
void fat_init(){
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -54,8 +23,6 @@ void fat_init(){
|
|||||||
sd_readblock(1, fat_buf);
|
sd_readblock(1, fat_buf);
|
||||||
sd_readblock(32, fat_buf);
|
sd_readblock(32, fat_buf);
|
||||||
|
|
||||||
fat_print_pbp_info(&bpb);
|
|
||||||
|
|
||||||
data_region_start = bpb.reserved_sectors + bpb.fat_count*bpb.sectors_per_fat_32;
|
data_region_start = bpb.reserved_sectors + bpb.fat_count*bpb.sectors_per_fat_32;
|
||||||
|
|
||||||
sd_readblock(bpb.reserved_sectors, fat_buf);
|
sd_readblock(bpb.reserved_sectors, fat_buf);
|
||||||
@@ -73,25 +40,6 @@ void fat_init(){
|
|||||||
cprintf("End of chain indicator: %lx\n", fat_end_of_chain);
|
cprintf("End of chain indicator: %lx\n", fat_end_of_chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fat_read(char* filename, void* buf) {
|
|
||||||
vfat_dentry_t* vfat_dentry;
|
|
||||||
dos_dentry_t* dos_dentry;
|
|
||||||
uint32_t cluster;
|
|
||||||
|
|
||||||
(void)filename; //just ignore filename
|
|
||||||
|
|
||||||
sd_readblock(data_region_start, buf);
|
|
||||||
|
|
||||||
vfat_dentry = (vfat_dentry_t*)buf;
|
|
||||||
while(vfat_dentry->sequence_number == 0xe5)
|
|
||||||
vfat_dentry++;
|
|
||||||
|
|
||||||
dos_dentry = (dos_dentry_t*)(vfat_dentry + 1);
|
|
||||||
|
|
||||||
cluster = ((uint32_t)dos_dentry->first_cluster_h << 16) + dos_dentry->first_cluster_l;
|
|
||||||
|
|
||||||
sd_readblock(data_region_start + (cluster - 2) * 8, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure you have enough space.
|
// make sure you have enough space.
|
||||||
void fat_read_cluster(uint16_t cluster, uint8_t* buf) {
|
void fat_read_cluster(uint16_t cluster, uint8_t* buf) {
|
||||||
|
|||||||
@@ -113,9 +113,7 @@ typedef struct {
|
|||||||
uint32_t file_size;
|
uint32_t file_size;
|
||||||
} dos_dentry_t;
|
} dos_dentry_t;
|
||||||
|
|
||||||
void fat_print_pbp_info(full_bpb_t* bpb);
|
|
||||||
void fat_init();
|
void fat_init();
|
||||||
void fat_read(char* filename, void* buf);
|
|
||||||
|
|
||||||
uint16_t fat_parse_path_to_cluster(char* filename);
|
uint16_t fat_parse_path_to_cluster(char* filename);
|
||||||
void fat_read_cluster(uint16_t cluster, uint8_t* buf);
|
void fat_read_cluster(uint16_t cluster, uint8_t* buf);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "devices/mapper.h"
|
#include "devices/mapper.h"
|
||||||
#include "devices/sd_card.h"
|
#include "devices/sd_card.h"
|
||||||
#include "filesystem/fat.h"
|
#include "filesystem/fat.h"
|
||||||
#include "exec.h"
|
|
||||||
|
|
||||||
#define KERNEL_LOAD_ADDR 0xD000
|
#define KERNEL_LOAD_ADDR 0xD000
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void fat_print_pbp_info(full_bpb_t* bpb){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fat_init(){
|
void fat_init(){
|
||||||
int i;
|
//int i;
|
||||||
|
|
||||||
sd_readblock(0, fat_buf);
|
sd_readblock(0, fat_buf);
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,11 @@
|
|||||||
uint8_t buf[512];
|
uint8_t buf[512];
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i;
|
|
||||||
uint16_t rca;
|
uint16_t rca;
|
||||||
char* filename;
|
char* filename;
|
||||||
|
|
||||||
clrscr();
|
clrscr();
|
||||||
cprintf("Hello, world!\n");
|
cprintf("Hello, world! Modified\n");
|
||||||
|
|
||||||
for (i = 0; i < 16; i++){
|
|
||||||
//cprintf("Mapping %1xxxx to %2xxxx\n", i, i);
|
|
||||||
mapper_write(i, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
cprintf("Enabling Mapper\n");
|
|
||||||
mapper_enable(1);
|
|
||||||
|
|
||||||
sd_init();
|
sd_init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user