ISO初步建立

This commit is contained in:
xiaoyi1212 2024-05-27 00:03:20 +08:00
parent 9144d9f3bf
commit 79cef43d29
19 changed files with 1170 additions and 136 deletions

View File

@ -0,0 +1 @@

View File

@ -4,13 +4,10 @@
#include "../include/vdisk.h" #include "../include/vdisk.h"
#include "../include/timer.h" #include "../include/timer.h"
#include "../include/pci.h" #include "../include/pci.h"
#include "../include/printf.h"
static inline nul(char *f, ...) {}
#define logk nul
#define inb io_in8 #define inb io_in8
#define outb io_out8 #define outb io_out8
struct IDEChannelRegisters { struct IDEChannelRegisters {
unsigned short base; // I/O Base. unsigned short base; // I/O Base.
unsigned short ctrl; // Control Base unsigned short ctrl; // Control Base
@ -55,6 +52,8 @@ static void Write(char drive, unsigned char *buffer, unsigned int number,
void ide_initialize(unsigned int BAR0, unsigned int BAR1, unsigned int BAR2, void ide_initialize(unsigned int BAR0, unsigned int BAR1, unsigned int BAR2,
unsigned int BAR3, unsigned int BAR4) { unsigned int BAR3, unsigned int BAR4) {
register_interrupt_handler(0x2f,ide_irq);
register_interrupt_handler(0x2e,ide_irq);
int j, k, count = 0; int j, k, count = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
ide_devices[i].Reserved = 0; ide_devices[i].Reserved = 0;
@ -162,16 +161,21 @@ void ide_initialize(unsigned int BAR0, unsigned int BAR1, unsigned int BAR2,
vdisk vd; vdisk vd;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
if (ide_devices[i].Reserved == 1) { if (ide_devices[i].Reserved == 1) {
logk(" %d Found %s Drive %dMB - %s\n", i, logkf(" %d Found %s Drive %dMB - %s\n", i,
(const char *[]) {"ATA", "ATAPI"}[ide_devices[i].Type], /* Type */ (const char *[]) {"ATA", "ATAPI"}[ide_devices[i].Type], /* Type */
ide_devices[i].Size / 1024 / 2, /* Size */ ide_devices[i].Size / 1024 / 2, /* Size */
ide_devices[i].Model); ide_devices[i].Model);
strcpy(vd.DriveName, ide_devices[i].Model); strcpy(vd.DriveName, ide_devices[i].Model);
if(ide_devices[i].Type == IDE_ATAPI) {
vd.flag = 2;
} else {
vd.flag = 1; vd.flag = 1;
}
vd.Read = Read; vd.Read = Read;
vd.Write = Write; vd.Write = Write;
vd.size = ide_devices[i].Size; vd.size = ide_devices[i].Size;
printf("[Disk-(%c)]: Size: %dMB | Name: %s\n", register_vdisk(vd), vd.size, vd.DriveName); printf("[Disk-(%c)]: Size: %dMB | %s | Name: %s\n", register_vdisk(vd), vd.size,(const char *[]) {"ATA", "ATAPI"}[ide_devices[i].Type], vd.DriveName);
} }
} }
@ -241,7 +245,7 @@ unsigned char ide_polling(unsigned char channel, unsigned int advanced_check) {
logk("II\n"); logk("II\n");
int a = ide_read(channel, ATA_REG_STATUS); int a = ide_read(channel, ATA_REG_STATUS);
while (a & ATA_SR_BSY) { while (a & ATA_SR_BSY) {
logk("a=%d\n", a & ATA_SR_BSY); // Wait for BSY to be zero. logkf("a=%d\n", a & ATA_SR_BSY); // Wait for BSY to be zero.
a = ide_read(channel, ATA_REG_STATUS); a = ide_read(channel, ATA_REG_STATUS);
sleep(1); sleep(1);
} }
@ -352,7 +356,7 @@ unsigned char ide_ata_access(unsigned char direction, unsigned char drive,
ide_write(channel, ATA_REG_CONTROL, ide_write(channel, ATA_REG_CONTROL,
channels[channel].nIEN = (ide_irq_invoked = 0x0) + 0x02); channels[channel].nIEN = (ide_irq_invoked = 0x0) + 0x02);
// (I) Select one from LBA28, LBA48 or CHS; // (I) Select one from LBA28, LBA48 or CHS;
logk("I %02x\n", channels[channel].nIEN); logkf("I %02x\n", channels[channel].nIEN);
if (lba >= 0x10000000) { // Sure Drive should support LBA in this case, or if (lba >= 0x10000000) { // Sure Drive should support LBA in this case, or
// you are giving a wrong LBA. // you are giving a wrong LBA.
// LBA48: // LBA48:
@ -453,7 +457,7 @@ unsigned char ide_ata_access(unsigned char direction, unsigned char drive,
if (err = ide_polling(channel, 1)) if (err = ide_polling(channel, 1))
return err; // Polling, set error and exit if there is. return err; // Polling, set error and exit if there is.
logk("words=%d bus=%d\n", words, bus); logkf("words=%d bus=%d\n", words, bus);
for (int h = 0; h < words; h++) { for (int h = 0; h < words; h++) {
unsigned short a = io_in16(bus); unsigned short a = io_in16(bus);
word_[i * words + h] = a; word_[i * words + h] = a;
@ -465,7 +469,7 @@ unsigned char ide_ata_access(unsigned char direction, unsigned char drive,
// PIO Write. // PIO Write.
uint16_t *word_ = edi; uint16_t *word_ = edi;
for (i = 0; i < numsects; i++) { for (i = 0; i < numsects; i++) {
logk("write %d\n", i); logkf("write %d\n", i);
ide_polling(channel, 0); // Polling. ide_polling(channel, 0); // Polling.
// asm("pushw %ds"); // asm("pushw %ds");
// asm("mov %%ax, %%ds" ::"a"(selector)); // asm("mov %%ax, %%ds" ::"a"(selector));
@ -485,8 +489,10 @@ unsigned char ide_ata_access(unsigned char direction, unsigned char drive,
} }
void ide_wait_irq() { void ide_wait_irq() {
logk("WAITING\n");
while (!ide_irq_invoked); while (!ide_irq_invoked);
ide_irq_invoked = 0; ide_irq_invoked = 0;
logk("IDE_WAIT_IRQ!\n");
} }
void ide_irq() { void ide_irq() {
@ -510,7 +516,7 @@ unsigned char ide_atapi_read(unsigned char drive, unsigned int lba,
channels[channel].nIEN = ide_irq_invoked = 0x0); channels[channel].nIEN = ide_irq_invoked = 0x0);
// (I): Setup SCSI Packet: // (I): Setup SCSI Packet:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
logk("I\n"); logk("CDROM I\n");
atapi_packet[0] = ATAPI_CMD_READ; atapi_packet[0] = ATAPI_CMD_READ;
atapi_packet[1] = 0x0; atapi_packet[1] = 0x0;
atapi_packet[2] = (lba >> 24) & 0xFF; atapi_packet[2] = (lba >> 24) & 0xFF;
@ -525,12 +531,12 @@ unsigned char ide_atapi_read(unsigned char drive, unsigned int lba,
atapi_packet[11] = 0x0; // (II): Select the drive: atapi_packet[11] = 0x0; // (II): Select the drive:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
ide_write(channel, ATA_REG_HDDEVSEL, slavebit << 4); ide_write(channel, ATA_REG_HDDEVSEL, slavebit << 4);
logk("II\n"); logk("CDROM II\n");
// (III): Delay 400 nanoseconds for select to complete: // (III): Delay 400 nanoseconds for select to complete:
for (int i = 0; i < 4000; i++); for (int i = 0; i < 4000; i++);
logk("III\n"); logk("CDROM III\n");
// ------------------------------------------------------------------ // ------------------------------------------------------------------
logk("IV\n"); logk("CDROM IV\n");
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
ide_read(channel, ide_read(channel,
ATA_REG_ALTSTATUS); // Reading the Alternate Status port wastes ATA_REG_ALTSTATUS); // Reading the Alternate Status port wastes
@ -541,7 +547,7 @@ unsigned char ide_atapi_read(unsigned char drive, unsigned int lba,
0); // PIO mode. 0); // PIO mode.
// (V): Tell the Controller the size of buffer: // (V): Tell the Controller the size of buffer:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
logk("V\n"); logk("CDROM V\n");
ide_write(channel, ATA_REG_LBA1, ide_write(channel, ATA_REG_LBA1,
(words * 2) & 0xFF); // Lower Byte of Sector Size. (words * 2) & 0xFF); // Lower Byte of Sector Size.
ide_write(channel, ATA_REG_LBA2, ide_write(channel, ATA_REG_LBA2,
@ -557,24 +563,22 @@ unsigned char ide_atapi_read(unsigned char drive, unsigned int lba,
// (VIII): Sending the packet data: // (VIII): Sending the packet data:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
logk("VIII\n"); logk("CDROM VIII\n");
uint16_t *_atapi_packet = atapi_packet; uint16_t *_atapi_packet = atapi_packet;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
io_out16(bus, _atapi_packet[i]); io_out16(bus, _atapi_packet[i]);
} }
// (IX): Receiving Data: // (IX): Receiving Data:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
logk("IX\n"); logk("CDROM IX\n");
uint16_t *_word = edi; uint16_t *_word = edi;
for (i = 0; i < numsects; i++) { for (i = 0; i < numsects; i++) {
ide_wait_irq(); // Wait for an IRQ. ide_wait_irq(); // Wait for an IRQ.
if (err = ide_polling(channel, 1)) if (err = ide_polling(channel, 1))
return err; // Polling and return if error. return err; // Polling and return if error.
logk("words = %d\n", words); logkf("CDROM words = %d\n", words);
for (int h = 0; h < words; h++) {
uint16_t a = io_in16(bus); insl(bus, _word + i * words, words / 2);
_word[i * words + h] = a;
}
} }
// (X): Waiting for an IRQ: // (X): Waiting for an IRQ:
// ------------------------------------------------------------------ // ------------------------------------------------------------------

146
src/driver/sb16.c Normal file
View File

@ -0,0 +1,146 @@
#include "../include/sb16.h"
#include "../include/io.h"
#include "../include/printf.h"
#include "../include/timer.h"
#include "../include/dma.h"
#include "../include/file.h"
struct sb16 sb;
void sb16_handler(registers_t *reg) {
io_in8(SB_INTR16);
uint8_t state = io_in8(SB_STATE);
logkf("sb16 handler state 0x%X...\n", state);
sb.flag = !sb.flag;
}
void disable_sb16() {
sb.addr = (char*)DMA_BUF_ADDR;
sb.mode = MODE_STEREO16;
sb.channel = 5;
sb.use_task = NULL;
register_interrupt_handler(SB16_IRQ + 0x20, sb16_handler);
}
static void sb_reset() {
io_out8(SB_RESET, 1);
sleep(1);
io_out8(SB_RESET, 0);
uint8_t state = io_in8(SB_READ);
logkf("sb16 reset state 0x%x\n", state);
}
static void sb_intr_irq() {
io_out8(SB_MIXER, 0x80);
uint8_t data = io_in8(SB_MIXER_DATA);
if (data != 2) {
io_out8(SB_MIXER, 0x80);
io_out8(SB_MIXER_DATA, 0x2);
}
}
static void sb_out(uint8_t cmd) {
while (io_in8(SB_WRITE) & 128)
;
io_out8(SB_WRITE, cmd);
}
static void sb_turn(bool on) {
if (on)
sb_out(CMD_ON);
else
sb_out(CMD_OFF);
}
static uint32_t sb_time_constant(uint8_t channels, uint16_t sample) {
return 65536 - (256000000 / (channels * sample));
}
static void sb_set_volume(uint8_t level) {
logkf("set sb16 volume to 0x%02X\n", level);
io_out8(SB_MIXER, 0x22);
io_out8(SB_MIXER_DATA, level);
}
int sb16_set(int cmd, void* args) {
switch (cmd) {
// 设置 tty 参数
case 0:
while (sb.use_task)
;
io_cli();
sb.use_task = get_current();
io_sti();
sb_reset(); // 重置 DSP
sb_intr_irq(); // 设置中断
sb_out(CMD_ON); // 打开声霸卡
return 0;
case 1:
sb_out(CMD_OFF); // 关闭声霸卡
sb.use_task = NULL;
return 0;
case 2:
sb.mode = MODE_MONO8;
sb.channel = 1;
return 0;
case 3:
sb.mode = MODE_STEREO16;
sb.channel = 5;
return 0;
case 4:
sb_set_volume((uint32_t)args & 0xff);
return 0;
default:
break;
}
return -1;
}
int sb16_write(char* data, size_t size) {
memcpy(sb.addr, data, size);
// 设置采样率
sb_out(CMD_SOSR); // 44100 = 0xAC44
sb_out((SAMPLE_RATE >> 8) & 0xFF); // 0xAC
sb_out(SAMPLE_RATE & 0xFF); // 0x44
dma_xfer(sb.channel, sb.addr, size, 0);
if (sb.mode == MODE_MONO8) {
sb_out(CMD_SINGLE_OUT8);
sb_out(MODE_MONO8);
} else {
sb_out(CMD_SINGLE_OUT16);
sb_out(MODE_STEREO16);
size >>= 2; // size /= 4
}
sb_out((size - 1) & 0xFF);
sb_out(((size - 1) >> 8) & 0xFF);
sb.flag = 0;
//while (!sb.flag);
return size;
}
void wav_player(char* filename) {
FILE* fp = fopen(filename, "rb");
if(fp == NULL) {
logk("Open wav file was throw error.\n");
return;
}
char* buf = kmalloc(DMA_BUF_SIZE);
fread(buf, 1, 44, fp);
logk("SB3 I\n");
sb16_set(0, 0);
logk("SB3 II\n");
sb16_set(2, 0);
logk("SB3 III\n");
sb16_set(4, 0xff);
logk("SB3 IV\n");
int sz;
while (sz = fread(buf, 1, DMA_BUF_SIZE, fp)) {
logkf("%02x ",sz);
sb16_write(buf, sz);
}
logk("\nSB3 IIV\n");
sb16_set(1, 0);
logk("SB3 IIIV\n");
fclose(fp);
}

39
src/driver/serial.c Normal file
View File

@ -0,0 +1,39 @@
#include "../include/serial.h"
#include "../include/io.h"
int init_serial() {
io_out8(SERIAL_PORT + 1, 0x00); // 禁止COM的中断发生
io_out8(SERIAL_PORT + 3, 0x80); // 启用DLAB设置波特率除数
io_out8(SERIAL_PORT + 0, 0x03); // 设置除数为3(低位) 38400波特
io_out8(SERIAL_PORT + 1, 0x00); // (高位)
io_out8(SERIAL_PORT + 3, 0x03); // 8位无奇偶性一个停止位
io_out8(SERIAL_PORT + 2, 0xC7); // 启用FIFO有14字节的阈值
io_out8(SERIAL_PORT + 4, 0x0B); // 启用IRQ设置RTS/DSR
io_out8(SERIAL_PORT + 4, 0x1E); // 设置为环回模式,测试串口
io_out8(SERIAL_PORT + 0, 0xAE); // 测试串口发送字节0xAE并检查串口是否返回相同的字节
// 检查串口是否有问题(即:与发送的字节不一样)
if (io_in8(SERIAL_PORT + 0) != 0xAE) {
return 1;
}
// 如果串口没有故障,将其设置为正常运行模式。
// (非环回启用IRQ启用OUT#1和OUT#2位)
io_out8(SERIAL_PORT + 4, 0x0F);
return 0;
}
int serial_received() { return io_in8(SERIAL_PORT + 5) & 1; }
char read_serial() {
while (serial_received() == 0)
;
return io_in8(SERIAL_PORT);
}
int is_transmit_empty() { return io_in8(SERIAL_PORT + 5) & 0x20; }
void write_serial(char a) {
while (is_transmit_empty() == 0)
;
io_out8(SERIAL_PORT, a);
}

View File

@ -14,8 +14,9 @@ uint32_t *screen;
uint32_t *char_buffer; uint32_t *char_buffer;
extern uint8_t ascfont[]; extern uint8_t ascfont[];
extern uint8_t plfont[]; extern uint8_t plfont[];
extern uint8_t bafont[];
bool vbe_status; bool vbe_status = false;
static void copy_char(uint32_t *vram, int off_x, int off_y, int x, int y, int x1, static void copy_char(uint32_t *vram, int off_x, int off_y, int x, int y, int x1,
int y1, int xsize) { int y1, int xsize) {
@ -81,9 +82,10 @@ void vbe_draw_char(char c, int32_t x, int32_t y) {
} }
uint8_t *font = ascfont; uint8_t *font = bafont;
font += c * 16; font += c * 16;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
if (font[i] & (0x80 >> j)) { if (font[i] & (0x80 >> j)) {
@ -91,14 +93,17 @@ void vbe_draw_char(char c, int32_t x, int32_t y) {
} else screen[(y + i) * width + x + j] = back_color; } else screen[(y + i) * width + x + j] = back_color;
} }
} }
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 9; j++) {
if (font[i] & (0x80 >> j)) {
screen[(y + i) * width + x + j] = color;
} else screen[(y + i) * width + x + j + 1] = back_color;
}
}
} }
int cur_task() { int cur_task() {
return 0;
while (1) { while (1) {
vbe_draw_char('_', x, y);
clock_sleep(5);
vbe_draw_char(' ', x, y);
clock_sleep(5); clock_sleep(5);
} }
} }
@ -131,14 +136,13 @@ void vbe_putchar(char ch) {
if (cy != 0) cy -= 1; if (cy != 0) cy -= 1;
if (cy == 0) cx = 0, cy = 0; if (cy == 0) cx = 0, cy = 0;
} }
draw_rect(x, y, x + 9, y + 16, 0); //draw_rect(x, y, x + 9, y + 16, back_color);
return; return;
} }
vbe_scroll(); vbe_scroll();
vbe_draw_char(ch, cx * 9 - 7, cy * 16); vbe_draw_char(ch, cx * 9 - 7, cy * 16);
} }
void vbe_write(const char *data, size_t size) { void vbe_write(const char *data, size_t size) {
@ -169,7 +173,7 @@ void initVBE(multiboot_t *info) {
width = info->framebuffer_width; width = info->framebuffer_width;
height = info->framebuffer_height; height = info->framebuffer_height;
color = 0xc6c6c6; color = 0xc6c6c6;
back_color = 0x191f42; back_color = 0x343541;
c_width = width / 9; c_width = width / 9;
c_height = height / 16; c_height = height / 16;

View File

@ -102,9 +102,27 @@ void DriveSemaphoreGive(unsigned int drive_code) {
return; return;
} }
void Disk_Read2048(unsigned int lba, unsigned int number, void *buffer,
char drive){
if(have_vdisk(drive)){
if (DriveSemaphoreTake(GetDriveCode((unsigned char *)"DISK_DRIVE"))) {
for (int i = 0; i < number; i+=SECTORS_ONCE) {
int sectors = ((number - i) >= SECTORS_ONCE) ? SECTORS_ONCE : (number - i);
rw_vdisk(drive, lba + i, buffer + i * 2048, sectors, 1);
}
DriveSemaphoreGive(GetDriveCode((unsigned char *)"DISK_DRIVE"));
}
}
}
void Disk_Read(unsigned int lba, unsigned int number, void *buffer, void Disk_Read(unsigned int lba, unsigned int number, void *buffer,
char drive) { char drive) {
if (have_vdisk(drive)) { if (have_vdisk(drive)) {
int indx = drive - ('A');
if(vdisk_ctl[indx].flag != 1) {
memset(buffer,0,number*512);
return;
}
if (DriveSemaphoreTake(GetDriveCode((unsigned char *)"DISK_DRIVE"))) { if (DriveSemaphoreTake(GetDriveCode((unsigned char *)"DISK_DRIVE"))) {
for (int i = 0; i < number; i += SECTORS_ONCE) { for (int i = 0; i < number; i += SECTORS_ONCE) {
int sectors = ((number - i) >= SECTORS_ONCE) ? SECTORS_ONCE : (number - i); int sectors = ((number - i) >= SECTORS_ONCE) ? SECTORS_ONCE : (number - i);
@ -114,6 +132,24 @@ void Disk_Read(unsigned int lba, unsigned int number, void *buffer,
} }
} }
} }
bool CDROM_Read(unsigned int lba, unsigned int number, void *buffer,
char drive) {
if (have_vdisk(drive)) {
int indx = drive - ('A');
if(vdisk_ctl[indx].flag != 2) {
return false;
}
if (DriveSemaphoreTake(GetDriveCode((unsigned char *)"DISK_DRIVE"))) {
for (int i = 0; i < number; i += SECTORS_ONCE) {
int sectors = ((number - i) >= SECTORS_ONCE) ? SECTORS_ONCE : (number - i);
rw_vdisk(drive, lba + i, buffer + i * 2048, sectors, 1);
}
DriveSemaphoreGive(GetDriveCode((unsigned char *)"DISK_DRIVE"));
}
return true;
}
return false;
}
unsigned int disk_Size(char drive) { unsigned int disk_Size(char drive) {
unsigned char drive1 = drive; unsigned char drive1 = drive;
if (have_vdisk(drive1)) { if (have_vdisk(drive1)) {

194
src/fs/file.c Normal file
View File

@ -0,0 +1,194 @@
#include "../include/file.h"
#include "../include/vfs.h"
#include "../include/memory.h"
#include "../include/printf.h"
#include <stdarg.h>
int fputc(int ch, FILE *stream) {
if (CANWRITE(stream->mode)) {
// printk("Current Buffer=%s\n",stream->buffer);
if (stream->p >= stream->bufferSize) {
// printk("Realloc....(%d,%d)\n",stream->p,stream->bufferSize);
stream->buffer = realloc(stream->buffer, stream->bufferSize + 100);
stream->bufferSize += 100;
}
if (stream->p >= stream->fileSize) {
stream->fileSize++;
}
// printk("Current Buffer=%s(A)\n",stream->buffer);
stream->buffer[stream->p++] = ch;
// printk("Current Buffer=%s(B)\n",stream->buffer);
return ch;
}
return EOF;
}
unsigned int fwrite(const void *ptr, unsigned int size, unsigned int nmemb,
FILE *stream) {
if (CANWRITE(stream->mode)) {
unsigned char *c_ptr = (unsigned char *)ptr;
for (int i = 0; i < size * nmemb; i++) {
fputc(c_ptr[i], stream);
}
return nmemb;
} else {
return 0;
}
}
FILE *fopen(char *filename, char *mode) {
unsigned int flag = 0;
FILE *fp = (FILE *)kmalloc(sizeof(FILE));
while (*mode != '\0') {
switch (*mode) {
case 'a':
flag |= APPEND;
break;
case 'b':
break;
case 'r':
flag |= READ;
break;
case 'w':
flag |= WRITE;
break;
case '+':
flag |= PLUS;
break;
default:
break;
}
mode++;
}
if (vfs_filesize(filename) == -1) {
kfree(fp);
logk("NULL FILE\n");
return NULL; // 找不到
} else if (flag & WRITE) {
char buffe2[100];
}
if (flag & WRITE) {
fp->fileSize = 0;
} else {
fp->fileSize = vfs_filesize(filename);
}
fp->bufferSize = 0;
if (flag & READ || flag & PLUS || flag & APPEND) {
fp->bufferSize = vfs_filesize(filename);
}
if (flag & WRITE || flag & PLUS || flag & APPEND) {
fp->bufferSize += 100;
}
if (fp->bufferSize == 0) {
fp->bufferSize = 1;
}
fp->buffer = kmalloc(fp->bufferSize);
if (flag & PLUS || flag & APPEND || flag & READ) {
// printk("ReadFile........\n");
vfs_readfile(filename, fp->buffer);
}
fp->p = 0;
if (flag & APPEND) {
fp->p = fp->fileSize;
}
fp->name = kmalloc(strlen(filename) + 1);
strcpy(fp->name, filename);
fp->mode = flag;
return fp;
}
int fgetc(FILE *stream) {
if (CANREAD(stream->mode)) {
if (stream->p >= stream->fileSize) {
return EOF;
} else {
return stream->buffer[stream->p++];
}
} else {
return EOF;
}
}
unsigned int fread(void *buffer, unsigned int size, unsigned int count,
FILE *stream) {
if (CANREAD(stream->mode)) {
unsigned char *c_ptr = (unsigned char *)buffer;
for (int i = 0; i < size * count; i++) {
unsigned int ch = fgetc(stream);
if (ch == EOF) {
return i;
} else {
c_ptr[i] = ch;
}
}
return count;
} else {
return 0;
}
}
int fclose(FILE *fp) {
if (fp == NULL) {
return EOF;
}
if (CANWRITE(fp->mode)) {
// printk("Save file.....(%s) Size =
//%d\n",fp->buffer,fp->fileSize);
// Edit_File(fp->name, fp->buffer, fp->fileSize, 0);
vfs_writefile(fp->name, fp->buffer, fp->fileSize);
}
kfree(fp->buffer);
kfree(fp->name);
kfree(fp);
return 0;
}
char *fgets(char *str, int n, FILE *stream) {
if (CANREAD(stream->mode)) {
for (int i = 0; i < n; i++) {
unsigned int ch = fgetc(stream);
if (ch == EOF) {
if (i == 0) {
return NULL;
} else {
break;
}
}
if (ch == '\n') {
break;
}
str[i] = ch;
}
return str;
}
return NULL;
}
int fputs(const char *str, FILE *stream) {
if (CANWRITE(stream->mode)) {
for (int i = 0; i < strlen(str); i++) {
fputc(str[i], stream);
}
return 0;
}
return EOF;
}
int fprintf(FILE *stream, const char *format, ...) {
if (CANWRITE(stream->mode)) {
int len;
va_list ap;
va_start(ap, format);
char *buf = kmalloc(1024);
len = vsprintf(buf, format, ap);
fputs(buf, stream);
kfree(buf);
va_end(ap);
return len;
} else {
// printk("CAN NOT WRITE\n");
return EOF;
}
}

View File

@ -2,7 +2,8 @@
#include "../include/memory.h" #include "../include/memory.h"
#include "../include/vfs.h" #include "../include/vfs.h"
#include "../include/vdisk.h" #include "../include/vdisk.h"
#include "../include/printf.h"
bool read_sector(l9660_fs *fs, void *buf, uint32_t sector);
#define l9660_seekdir(dir, pos) (l9660_seek(&(dir)->file, L9660_SEEK_SET, (pos))) #define l9660_seekdir(dir, pos) (l9660_seek(&(dir)->file, L9660_SEEK_SET, (pos)))
#define l9660_telldir(dir) (l9660_tell(&(dir)->file)) #define l9660_telldir(dir) (l9660_tell(&(dir)->file))
@ -38,9 +39,12 @@ static char gbuf[2048];
#endif #endif
l9660_fs *fs; l9660_fs *fs;
l9660_dir *root_dir;
static char *strchrnul(const char *s, int c) { static char *strchrnul(const char *s, int c)
while (*s) { {
while (*s)
{
if ((*s++) == c) if ((*s++) == c)
break; break;
} }
@ -68,10 +72,11 @@ fnextsectpos(l9660_file
return (f->position + 2047) & ~2047; return (f->position + 2047) & ~2047;
} }
l9660_status l9660_openfs(l9660_fs *fs, bool (*read_sector)(l9660_fs *fs, void *buf, uint32_t sector,uint8_t disk_number),uint8_t disk_number){ l9660_status l9660_openfs(l9660_fs *fs, bool (*read_sector)(l9660_fs *fs, void *buf, uint32_t sector), uint8_t disk_number)
fs-> {
read_sector = read_sector; fs->read_sector = read_sector;
fs->disk_number = disk_number;
logkf("fs--- %08x\n",fs->read_sector);
#ifndef L9660_SINGLEBUFFER #ifndef L9660_SINGLEBUFFER
l9660_vdesc_primary *pvd = PVD(&fs->pvd); l9660_vdesc_primary *pvd = PVD(&fs->pvd);
#else #else
@ -79,37 +84,34 @@ last_file = NULL;
l9660_vdesc_primary *pvd = PVD(gbuf); l9660_vdesc_primary *pvd = PVD(gbuf);
#endif #endif
uint32_t idx = 0x10; uint32_t idx = 0x10;
for (;;) { for (;;)
{
// Read next sector // Read next sector
if (! if (!read_sector(fs, pvd, idx))
read_sector(fs, pvd, idx, disk_number return L9660_EIO;
))
return
L9660_EIO;
// Validate magic // Validate magic
if ( if (
memcmp(pvd memcmp(pvd
->hdr.magic, "CD001", 5) != 0) ->hdr.magic,
return "CD001", 5) != 0)
L9660_EBADFS; return L9660_EBADFS;
if (pvd->hdr.type == 1) if (pvd->hdr.type == 1)
break; // Found PVD break; // Found PVD
else if (pvd->hdr.type == 255) else if (pvd->hdr.type == 255)
return return L9660_EBADFS;
L9660_EBADFS;
} }
#ifdef L9660_SINGLEBUFFER #ifdef L9660_SINGLEBUFFER
memcpy(&fs->root_dir_ent, &pvd->root_dir_ent, pvd->root_dir_ent.length); memcpy(&fs->root_dir_ent, &pvd->root_dir_ent, pvd->root_dir_ent.length);
#endif #endif
return return L9660_OK;
L9660_OK;
} }
l9660_status l9660_fs_open_root(l9660_dir *dir, l9660_fs *fs) { l9660_status l9660_fs_open_root(l9660_dir *dir, l9660_fs *fs)
{
l9660_file *f = &dir->file; l9660_file *f = &dir->file;
#ifndef L9660_SINGLEBUFFER #ifndef L9660_SINGLEBUFFER
l9660_dirent *dirent = &PVD(&fs->pvd)->root_dir_ent; l9660_dirent *dirent = &PVD(&fs->pvd)->root_dir_ent;
@ -125,28 +127,35 @@ l9660_status l9660_fs_open_root(l9660_dir *dir, l9660_fs *fs) {
return L9660_OK; return L9660_OK;
} }
static l9660_status buffer(l9660_file *f) { static l9660_status buffer(l9660_file *f)
{
#ifdef L9660_SINGLEBUFFER #ifdef L9660_SINGLEBUFFER
last_file = f; last_file = f;
#endif #endif
logkf("%08x %08x\n",read_sector,f->fs->read_sector);
if (!f->fs->read_sector(f->fs, BUF(f), f->first_sector + f->position / 2048)) if (!f->fs->read_sector(f->fs, BUF(f), f->first_sector + f->position / 2048))
return L9660_EIO; return L9660_EIO;
else else
return L9660_OK; return L9660_OK;
} }
static l9660_status prebuffer(l9660_file *f) { static l9660_status prebuffer(l9660_file *f)
{
if (!HAVEBUFFER(f) || (f->position % 2048) == 0) if (!HAVEBUFFER(f) || (f->position % 2048) == 0)
return buffer(f); return buffer(f);
else return L9660_OK; else
return L9660_OK;
} }
static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char *name, bool isdir) { static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char *name, bool isdir)
{
l9660_status rv; l9660_status rv;
l9660_dirent *dent = NULL; l9660_dirent *dent = NULL;
if ((rv = l9660_seekdir(parent, 0))) return rv; if ((rv = l9660_seekdir(parent, 0)))
return rv;
do { do
{
const char *seg = name; const char *seg = name;
name = strchrnul(name, '/'); name = strchrnul(name, '/');
size_t seglen = name - seg; size_t seglen = name - seg;
@ -156,12 +165,14 @@ static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char
seg = "\0"; seg = "\0";
/* ISO9660 stores ".." as '\1' */ /* ISO9660 stores ".." as '\1' */
if (seglen == 2 && seg[0] == '.' && seg[1] == '.') { if (seglen == 2 && seg[0] == '.' && seg[1] == '.')
{
seg = "\1"; seg = "\1";
seglen = 1; seglen = 1;
} }
for (;;) { for (;;)
{
if ((rv = l9660_readdir(parent, &dent))) if ((rv = l9660_readdir(parent, &dent)))
return rv; return rv;
@ -200,10 +211,13 @@ static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char
parent = (l9660_dir *)child; parent = (l9660_dir *)child;
} while (*name); } while (*name);
if (isdir) { if (isdir)
{
if ((dent->flags & DENT_ISDIR) == 0) if ((dent->flags & DENT_ISDIR) == 0)
return L9660_ENOTDIR; return L9660_ENOTDIR;
} else { }
else
{
if ((dent->flags & DENT_ISDIR) != 0) if ((dent->flags & DENT_ISDIR) != 0)
return L9660_ENOTFILE; return L9660_ENOTFILE;
} }
@ -211,29 +225,33 @@ static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char
return L9660_OK; return L9660_OK;
} }
l9660_status l9660_opendirat(l9660_dir *dir, l9660_dir *parent, const char *path) { l9660_status l9660_opendirat(l9660_dir *dir, l9660_dir *parent, const char *path)
{
return openat_raw(&dir->file, parent, path, true); return openat_raw(&dir->file, parent, path, true);
} }
static inline unsigned aligneven(unsigned v) { static inline unsigned aligneven(unsigned v)
{
return v + (v & 1); return v + (v & 1);
} }
l9660_status l9660_readdir(l9660_dir *dir, l9660_dirent **pdirent) { l9660_status l9660_readdir(l9660_dir *dir, l9660_dirent **pdirent)
{
l9660_status rv; l9660_status rv;
l9660_file *f = &dir->file; l9660_file *f = &dir->file;
rebuffer: rebuffer:
if (f->position >= f->length) { if (f->position >= f->length)
{
*pdirent = NULL; *pdirent = NULL;
return L9660_OK; return L9660_OK;
} }
if ((rv = prebuffer(f))) if ((rv = prebuffer(f)))
return rv; return rv;
char *off = BUF(f) + fsectoff(f); char *off = BUF(f) + fsectoff(f);
if (*off == 0) { if (*off == 0)
{
// Padded end of sector // Padded end of sector
f->position = fnextsectpos(f); f->position = fnextsectpos(f);
goto rebuffer; goto rebuffer;
@ -246,16 +264,19 @@ l9660_status l9660_readdir(l9660_dir *dir, l9660_dirent **pdirent) {
return L9660_OK; return L9660_OK;
} }
l9660_status l9660_openat(l9660_file *child, l9660_dir *parent, const char *name) { l9660_status l9660_openat(l9660_file *child, l9660_dir *parent, const char *name)
{
return openat_raw(child, parent, name, false); return openat_raw(child, parent, name, false);
} }
/*! Seek the file to \p offset from \p whence */ /*! Seek the file to \p offset from \p whence */
l9660_status l9660_seek(l9660_file *f, int whence, int32_t offset) { l9660_status l9660_seek(l9660_file *f, int whence, int32_t offset)
{
l9660_status rv; l9660_status rv;
uint32_t cursect = fsector(f); uint32_t cursect = fsector(f);
switch (whence) { switch (whence)
{
case SEEK_SET: case SEEK_SET:
f->position = offset; f->position = offset;
break; break;
@ -269,7 +290,8 @@ l9660_status l9660_seek(l9660_file *f, int whence, int32_t offset) {
break; break;
} }
if (fsector(f) != cursect && fsectoff(f) != 0) { if (fsector(f) != cursect && fsectoff(f) != 0)
{
if ((rv = buffer(f))) if ((rv = buffer(f)))
return rv; return rv;
} }
@ -277,11 +299,13 @@ l9660_status l9660_seek(l9660_file *f, int whence, int32_t offset) {
return L9660_OK; return L9660_OK;
} }
uint32_t l9660_tell(l9660_file *f) { uint32_t l9660_tell(l9660_file *f)
{
return f->position; return f->position;
} }
l9660_status l9660_read(l9660_file *f, void *buf, size_t size, size_t *read) { l9660_status l9660_read(l9660_file *f, void *buf, size_t size, size_t *read)
{
l9660_status rv; l9660_status rv;
if ((rv = prebuffer(f))) if ((rv = prebuffer(f)))
@ -301,28 +325,172 @@ l9660_status l9660_read(l9660_file *f, void *buf, size_t size, size_t *read) {
return L9660_OK; return L9660_OK;
} }
bool read_sector(l9660_fs *fs, void *buf, uint32_t sector,uint8_t disk_number){ bool read_sector(l9660_fs *fs, void *buf, uint32_t sector)
return false; {
return CDROM_Read(sector,1,buf,fs->disk_number);
} }
bool ISO_Check(uint8_t disk_number){ bool ISO_Check(uint8_t disk_number)
l9660_openfs(fs,read_sector,disk_number); {
return false; unsigned char *buffer = kmalloc(2049); // 假设扇区大小为 2048 字节
bool ok = CDROM_Read(16, 1, buffer, disk_number);
if (buffer[0] == 0x01 && buffer[1] == 'C' && buffer[2] == 'D' && buffer[3] == '0' &&
buffer[4] == '0' && buffer[5] == '1')
{
kfree(buffer);
return true; // 是 ISO9660 文件系统
}
else
{
kfree(buffer);
return false; // 不是 ISO9660 文件系统
}
} }
void ISO_InitFs(struct vfs_t *vfs, uint8_t disk_number){ void ISO_InitFs(struct vfs_t *vfs, uint8_t disk_number)
{
fs = (l9660_fs *)kmalloc(sizeof(l9660_fs));
vfs->cache = (void *)fs;
printf("ISO Load init...");
l9660_status a = l9660_openfs(fs,read_sector,disk_number);
a = l9660_fs_open_root(root_dir, fs);
printf("%d\n",a);
/*
l9660_file file;
for (;;) {
l9660_dirent *dent;
l9660_readdir(root_dir, &dent);
if (dent == 0)
break;
printf("%.*s\n", dent->name_len, dent->name);
}
a = l9660_openat(&file, dir, "fuck.txt");
if(a) {
printf("failed\n");
for(;;);
}
for(;;) {
char buf[128];
size_t read;
l9660_read(&file, buf, 128, &read);
if (read == 0)
break;
for(int i = 0;i<read;i++) {
printf("%c",buf[i]);
}
}
while (1)
asm("hlt");
*/
}
void ISO_CDFile(){}
vfs_file *ISO_GetFile(char* path1){
l9660_dir bmpDict;
char *path = (char *)kmalloc(strlen(path1) + 1);
char *bmp = path;
strcpy(path, path1);
strtoupper(path);
if (strncmp("/", path, 1) == 0) {
path += 1;
bmpDict = root_dir;
}
if (path[0] == '\\' || path[0] == '/') {
// 跳过反斜杠和正斜杠
for (int i = 0; i < strlen(path); i++) {
if (path[i] != '\\' && path[i] != '/') {
path += i;
break;
}
}
}
char *temp_name = (char *)kmalloc(128);
int i = 0;
l9660_file *finfo;
while (1) {
int j;
for (j = 0; i < strlen(path); i++, j++) {
if (path[i] == '\\' || path[i] == '/') {
temp_name[j] = '\0';
i++;
break;
}
temp_name[j] = path[i];
}
finfo = dict_search(temp_name, bmpDict, get_directory_max(bmpDict, vfs));
if (finfo == 0) {
if (path[i] != 0) {
bmpDict = NULL;
}
goto END;
} else {
if (get_clustno(finfo->clustno_high, finfo->clustno_low) != 0) {
for (int count = 1;
FindForCount(count, get_dm(vfs).directory_clustno_list) != NULL;
count++) {
struct List *list =
FindForCount(count, get_dm(vfs).directory_clustno_list);
if (get_clustno(finfo->clustno_high, finfo->clustno_low) ==
list->val) {
list = FindForCount(count, get_dm(vfs).directory_list);
bmpDict = (struct FAT_FILEINFO *)list->val;
break;
}
}
} else {
bmpDict = root_dir;
}
memclean(temp_name, 128);
if (path[i] == '\0') {
goto END;
}
}
}
END:
kfree((void *)temp_name);
kfree(((void *)bmp));
return bmpDict;
}
void ISO_CopyCache(struct vfs_t *dest, struct vfs_t *src){
dest->cache = kmalloc(sizeof(l9660_fs));
memcpy(dest->cache, src->cache, sizeof(l9660_fs));
}
void ISO_cd(struct vfs_t *vfs, char *dictName){
} }
void init_iso9660(){ void ISO_ReadFile(struct vfs_t *vfs, char *path, char *buffer){
}
void ISO_ListFile(struct vfs_t *vfs, char *dictpath){
}
void init_iso9660()
{
vfs_t fs; vfs_t fs;
fs.flag = 1; fs.flag = 1;
fs.cache = NULL; fs.cache = NULL;
strcpy(fs.FSName, "ISO9660"); strcpy(fs.FSName, "ISO9660");
fs.CopyCache = ISO_CopyCache;
fs.Check = ISO_Check; fs.Check = ISO_Check;
fs.InitFs = ISO_InitFs; fs.InitFs = ISO_InitFs;
fs.CreateFile = ISO_CDFile;
fs.CreateDict = ISO_CDFile;
fs.DelDict = ISO_CDFile;
fs.DelFile = ISO_CDFile;
fs.cd = ISO_cd;
fs.ReadFile = ISO_ReadFile;
fs.ListFile = ISO_ListFile;
vfs_register_fs(fs);
//vfs_register_fs(fs);
} }

View File

@ -60,6 +60,7 @@ static vfs_t *check_disk_fs(uint8_t disk_number) {
} }
} }
} }
return NULL; return NULL;
} }
@ -78,12 +79,12 @@ bool vfs_mount_disk(uint8_t disk_number, uint8_t drive) {
return false; return false;
} }
} }
vfs_t *seat = findSeat(vfsMount_Stl); vfs_t *seat = findSeat(vfsMount_Stl);
if (!seat) { if (!seat) {
printf("can not find a seat of vfsMount_Stl(it's full)\n"); printf("can not find a seat of vfsMount_Stl(it's full)\n");
return false; return false;
} }
vfs_t *fs = check_disk_fs(disk_number); vfs_t *fs = check_disk_fs(disk_number);
if (!fs) { if (!fs) {
printf("[FileSystem]: Unknown file system.\n"); printf("[FileSystem]: Unknown file system.\n");

28
src/include/file.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef CRASHPOWEROS_FILE_H
#define CRASHPOWEROS_FILE_H
#define EOF -1
#define CANREAD(flag) ((flag)&READ || (flag)&PLUS)
#define CANWRITE(flag) ((flag)&WRITE || (flag)&PLUS || (flag)&APPEND)
#define READ 0x2
#define WRITE 0x4
#define APPEND 0x8
#define BIN 0x0
#define PLUS 0x10
#include <stddef.h>
#include "vfs.h"
int fgetc(FILE *stream);
FILE *fopen(char *filename, char *mode);
unsigned int fread(void *buffer, unsigned int size, unsigned int count,
FILE *stream);
int fclose(FILE *fp);
char *fgets(char *str, int n, FILE *stream);
int fputs(const char *str, FILE *stream);
int fprintf(FILE *stream, const char *format, ...);
int fputc(int ch, FILE *stream);
unsigned int fwrite(const void *ptr, unsigned int size, unsigned int nmemb,
FILE *stream);
#endif

View File

@ -138,6 +138,7 @@ typedef struct l9660_fs {
/* read_sector func */ /* read_sector func */
bool (*read_sector)(struct l9660_fs *fs, void *buf, uint32_t sector); bool (*read_sector)(struct l9660_fs *fs, void *buf, uint32_t sector);
int disk_number;
} l9660_fs; } l9660_fs;
typedef struct { typedef struct {
@ -163,7 +164,7 @@ l9660_status l9660_openat(l9660_file *child, l9660_dir *parent, const char *name
l9660_status l9660_readdir(l9660_dir *dir, l9660_dirent **pdirent); l9660_status l9660_readdir(l9660_dir *dir, l9660_dirent **pdirent);
l9660_status l9660_opendirat(l9660_dir *dir, l9660_dir *parent, const char *path); l9660_status l9660_opendirat(l9660_dir *dir, l9660_dir *parent, const char *path);
l9660_status l9660_fs_open_root(l9660_dir *dir, l9660_fs *fs); l9660_status l9660_fs_open_root(l9660_dir *dir, l9660_fs *fs);
l9660_status l9660_openfs(l9660_fs *fs, bool (*read_sector)(l9660_fs *fs, void *buf, uint32_t sector,uint8_t disk_number),uint8_t disk_number); l9660_status l9660_openfs(l9660_fs *fs, bool (*read_sector)(l9660_fs *fs, void *buf, uint32_t sector),uint8_t disk_number);
void init_iso9660(); void init_iso9660();
#endif #endif

View File

@ -11,6 +11,8 @@ void printf(const char *formet, ...);
void print(char *message); void print(char *message);
void printk(const char *formet, ...); void printk(const char *formet, ...);
void putchar(char c); void putchar(char c);
void logk(char *message);
void logkf(char *formet,...);
void screen_clear(); void screen_clear();
#endif //CRASHPOWEROS_PRINTF_H #endif //CRASHPOWEROS_PRINTF_H

80
src/include/sb16.h Normal file
View File

@ -0,0 +1,80 @@
#ifndef CRASHPOWEROS_SB16_H
#define CRASHPOWEROS_SB16_H
#define SB_MIXER 0x224 // DSP 混合器端口
#define SB_MIXER_DATA 0x225 // DSP 混合器数据端口
#define SB_RESET 0x226 // DSP 重置
#define SB_READ 0x22A // DSP 读
#define SB_WRITE 0x22C // DSP 写
#define SB_STATE 0x22E // DSP 读状态
#define SB_INTR16 0x22F // DSP 16 位中断响应
#define CMD_STC 0x40 // Set Time Constant
#define CMD_SOSR 0x41 // Set Output Sample Rate
#define CMD_SISR 0x42 // Set Input Sample Rate
#define CMD_SINGLE_IN8 0xC8 // Transfer mode 8bit input
#define CMD_SINGLE_OUT8 0xC0 // Transfer mode 8bit output
#define CMD_SINGLE_IN16 0xB8 // Transfer mode 16bit input
#define CMD_SINGLE_OUT16 0xB0 // Transfer mode 16bit output
#define CMD_AUTO_IN8 0xCE // Transfer mode 8bit input auto
#define CMD_AUTO_OUT8 0xC6 // Transfer mode 8bit output auto
#define CMD_AUTO_IN16 0xBE // Transfer mode 16bit input auto
#define CMD_AUTO_OUT16 0xB6 // Transfer mode 16bit output auto
#define CMD_ON 0xD1 // Turn speaker on
#define CMD_OFF 0xD3 // Turn speaker off
#define CMD_SP8 0xD0 // Stop playing 8 bit channel
#define CMD_RP8 0xD4 // Resume playback of 8 bit channel
#define CMD_SP16 0xD5 // Stop playing 16 bit channel
#define CMD_RP16 0xD6 // Resume playback of 16 bit channel
#define CMD_VERSION 0xE1 // Turn speaker off
#define MODE_MONO8 0x00
// #define MODE_STEREO8 0x20
// #define MODE_MONO16 0x10
#define MODE_STEREO16 0x30
#define STATUS_READ 0x80 // read buffer status
#define STATUS_WRITE 0x80 // write buffer status
#define DMA_BUF_ADDR 0x90000 // 不能跨越 64K 边界
#define DMA_BUF_SIZE 0x8000 // 缓冲区长度
#define SAMPLE_RATE 44100 // 采样率
#define SB16_IRQ 5
#include "task.h"
#include "common.h"
#include "isr.h"
struct WAV16_HEADER {
char riff[4];
int size;
char wave[4];
char fmt[4];
int fmt_size;
short format;
short channel;
int sample_rate;
int byte_per_sec;
} __attribute__((packed));
struct sb16 {
struct task_struct *use_task;
int status;
char* addr; // DMA 地址
uint8_t mode; // 模式
uint8_t channel; // DMA 通道
uint8_t flag;
};
void disable_sb16();
void sb16_handler(registers_t *reg);
int sb16_set(int cmd, void* args);
int sb16_write(char* data, size_t size);
void wav_player(char* filename);
#endif

12
src/include/serial.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef CRASHPOWEROS_SERIAL_H
#define CRASHPOWEROS_SERIAL_H
#define SERIAL_PORT 0x3f8
int init_serial();
int serial_received();
char read_serial();
int is_transmit_empty();
void write_serial(char a);
#endif

View File

@ -40,12 +40,16 @@ int rw_vdisk(char drive, unsigned int lba, unsigned char *buffer,
int have_vdisk(char drive); int have_vdisk(char drive);
void Disk_Read(unsigned int lba, unsigned int number, void *buffer, void Disk_Read(unsigned int lba, unsigned int number, void *buffer,
char drive); char drive);
bool CDROM_Read(unsigned int lba, unsigned int number, void *buffer,
char drive);
unsigned int disk_Size(char drive); unsigned int disk_Size(char drive);
int DiskReady(char drive); int DiskReady(char drive);
void Disk_Write(unsigned int lba, unsigned int number, void *buffer, void Disk_Write(unsigned int lba, unsigned int number, void *buffer,
char drive); char drive);
unsigned int GetDriveCode(unsigned char *name); unsigned int GetDriveCode(unsigned char *name);
bool SetDrive(unsigned char *name); bool SetDrive(unsigned char *name);
void Disk_Read2048(unsigned int lba, unsigned int number, void *buffer,
char drive);
void DriveSemaphoreGive(unsigned int drive_code); void DriveSemaphoreGive(unsigned int drive_code);
bool DriveSemaphoreTake(unsigned int drive_code); bool DriveSemaphoreTake(unsigned int drive_code);

View File

@ -19,8 +19,11 @@
#include "../include/fat.h" #include "../include/fat.h"
#include "../include/iso9660.h" #include "../include/iso9660.h"
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))
extern uint32_t end; extern uint32_t end;
extern int status; extern int status;
extern vdisk vdisk_ctl[10];
uint32_t placement_address = (uint32_t) & end; uint32_t placement_address = (uint32_t) & end;
void reset_kernel(){ void reset_kernel(){
@ -68,7 +71,7 @@ void kernel_main(multiboot_t *multiboot) {
initVBE(multiboot); initVBE(multiboot);
printf("[kernel]: VGA driver load success!\n"); printf("[kernel]: VBE driver load success!\n");
gdt_install(); gdt_install();
idt_install(); idt_install();
printf("[kernel]: description table config success!\n"); printf("[kernel]: description table config success!\n");
@ -76,26 +79,37 @@ void kernel_main(multiboot_t *multiboot) {
acpi_install(); acpi_install();
printf("[kernel]: ACPI enable success!\n"); printf("[kernel]: ACPI enable success!\n");
init_page(multiboot); init_page(multiboot);
printf("[kernel]: page set success!\n"); printf("[kernel]: page set success!\n");
init_sched(); init_sched();
printf("[kernel]: task load success!\n"); printf("[kernel]: task load success!\n");
init_keyboard(); init_keyboard();
printf("[kernel]: Keyboard driver load success!\n"); printf("[kernel]: Keyboard driver load success!\n");
io_sti();
//kernel_thread(cur_task,NULL,"CPOS-VBE-SERVICE");
init_pit(); init_pit();
io_sti();
init_pci(); init_pci();
printf("[kernel]: PCI driver load success!\n");
init_vdisk(); init_vdisk();
ide_initialize(0x1F0, 0x3F6, 0x170, 0x376, 0x000); ide_initialize(0x1F0, 0x3F6, 0x170, 0x376, 0x000);
printf("[kernel]: Disk driver load success!\n");
init_vfs(); init_vfs();
Register_fat_fileSys(); Register_fat_fileSys();
printf("iso\n");
init_iso9660(); init_iso9660();
printf("[kernel]: FileSystem load success!\n");
syscall_install(); syscall_install();
vfs_mount_disk('A','A');
for (int i = 0; i < 10; i++) {
if (vdisk_ctl[i].flag) {
vdisk vd = vdisk_ctl[i];
char id = i + ('A');
vfs_mount_disk(id,id);
}
}
//vfs_mount_disk('A','A');
if(vfs_change_disk('A')) if(vfs_change_disk('A'))
printf("[FileSystem]: Change disk win!\n"); printf("[FileSystem]: Change disk win!\n");

View File

@ -6,6 +6,7 @@
#include "../include/cmos.h" #include "../include/cmos.h"
#include "../include/vdisk.h" #include "../include/vdisk.h"
#include "../include/vfs.h" #include "../include/vfs.h"
#include "../include/sb16.h"
extern Queue *key_char_queue; extern Queue *key_char_queue;
extern vdisk vdisk_ctl[10]; extern vdisk vdisk_ctl[10];
@ -213,6 +214,14 @@ void cmd_cd(int argc, char **argv) {
if (vfs_change_path(argv[1]) == 0) printf("Invalid path.\n"); if (vfs_change_path(argv[1]) == 0) printf("Invalid path.\n");
} }
void cmd_sb3(int argc, char **argv) {
if (argc == 1) {
print("[Shell-SB3]: If there are too few parameters, please specify the path.\n");
return;
}
wav_player(argv[1]);
}
void cmd_type(int argc,char ** argv){ void cmd_type(int argc,char ** argv){
if (argc == 1) { if (argc == 1) {
print("[Shell-TYPE]: If there are too few parameters, please specify the path.\n"); print("[Shell-TYPE]: If there are too few parameters, please specify the path.\n");
@ -247,6 +256,19 @@ void cmd_disk(int argc, char **argv) {
} }
printf("\n"); printf("\n");
return; return;
} else if(!strcmp("cg", argv[1])){
if(argc < 2){
printf("Please type disk ID\n");
return;
}
if (strlen(argv[2]) > 1) {
printf("[DISK]: Cannot found disk.\n");
return;
}
if(have_vdisk(argv[2][0])){
vfs_change_disk(argv[2][0]);
} else printf("[DISK]: Cannot found disk.\n");
return;
} }
if (strlen(argv[1]) > 1) { if (strlen(argv[1]) > 1) {
@ -370,6 +392,8 @@ void setup_shell() {
cmd_disk(argc, argv); cmd_disk(argc, argv);
else if (!strcmp("cd", argv[0])) else if (!strcmp("cd", argv[0]))
cmd_cd(argc, argv); cmd_cd(argc, argv);
else if (!strcmp("sb3", argv[0]))
cmd_sb3(argc, argv);
else if (!strcmp("help", argv[0]) || !strcmp("?", argv[0]) || !strcmp("h", argv[0])) { else if (!strcmp("help", argv[0]) || !strcmp("?", argv[0]) || !strcmp("h", argv[0])) {
print("-=[CoolPotShell Helper]=-\n"); print("-=[CoolPotShell Helper]=-\n");
print("help ? h Print shell help info.\n"); print("help ? h Print shell help info.\n");
@ -383,8 +407,9 @@ void setup_shell() {
print("reset Reset OS.\n"); print("reset Reset OS.\n");
print("shutdown exit Shutdown OS.\n"); print("shutdown exit Shutdown OS.\n");
print("debug Print os debug info.\n"); print("debug Print os debug info.\n");
print("disk [list|<ID>] List or view disks.\n"); print("disk[list|<ID>|cg<ID>]List or view disks.\n");
print("cd <path> Change shell top directory.\n"); print("cd <path> Change shell top directory.\n");
print("sb3 <name> Player a wav sound file.\n");
} else printf("\033[Shell]: Unknown command '%s'.\n", argv[0]); } else printf("\033[Shell]: Unknown command '%s'.\n", argv[0]);
} }
} }

View File

@ -507,3 +507,262 @@ const uint8_t plfont[] =
0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3c,0x44,0x42,0x42,0xe7,0x00,0x00, 0x00,0x00,0x00,0x10,0x10,0x18,0x28,0x28,0x24,0x3c,0x44,0x42,0x42,0xe7,0x00,0x00,
}; };
uint8_t bafont[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x44,0x82,0xaa,0xaa,0x82,0x82,0xaa,0x92,0x44,0x38,0x00,0x00,0x00,
0x00,0x00,0x38,0x7c,0xfe,0xd6,0xd6,0xfe,0xfe,0xd6,0xee,0x7c,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x6c,0xfe,0xfe,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x7c,0xfe,0x7c,0x38,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x54,0xfe,0x54,0x10,0x38,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x7c,0xfe,0xd6,0x10,0x38,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xff,0xff,0xff,0xff,
0x00,0x10,0x38,0x54,0x92,0x10,0x10,0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x00,0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x10,0x10,0xfe,0x10,0x10,0x10,0x00,0x00,
0x00,0x00,0x0c,0x0e,0x0b,0x0b,0x0a,0x08,0x08,0x18,0x78,0xf8,0x70,0x00,0x00,0x00,
0x00,0x00,0x1f,0x1f,0x11,0x11,0x11,0x11,0x11,0x11,0x77,0xff,0x66,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x54,0x38,0x28,0x38,0x54,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x00,
0x00,0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0x7e,0x3e,0x1e,0x0e,0x06,0x02,0x00,0x00,
0x00,0x00,0x10,0x38,0x54,0x92,0x10,0x10,0x10,0x92,0x54,0x38,0x10,0x00,0x00,0x00,
0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x44,0x44,0x00,0x00,
0x00,0x3e,0x4a,0x8a,0x8a,0x8a,0x8a,0x4a,0x3a,0x0a,0x0a,0x0a,0x0a,0x0a,0x00,0x00,
0x7c,0x82,0x40,0x20,0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x08,0x04,0x82,0x7c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xfe,0xfe,0x00,0x00,
0x00,0x00,0x10,0x38,0x54,0x92,0x10,0x10,0x10,0x92,0x54,0x38,0x10,0x7c,0x00,0x00,
0x00,0x10,0x38,0x54,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x92,0x54,0x38,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x08,0x04,0xfe,0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x20,0x40,0xfe,0x40,0x20,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xfe,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x28,0x44,0xfe,0x44,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x10,0x38,0x38,0x7c,0x7c,0xfe,0xfe,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xfe,0xfe,0x7c,0x7c,0x38,0x38,0x10,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x66,0x66,0x22,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x44,0x44,0x44,0xfe,0x44,0x44,0xfe,0x44,0x44,0x44,0x00,0x00,0x00,
0x10,0x10,0x7c,0x92,0x92,0x50,0x38,0x14,0x92,0x92,0x7c,0x10,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x92,0x96,0x6c,0x18,0x30,0x6c,0xd2,0x92,0x0c,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x44,0x38,0x20,0x76,0x88,0x88,0x88,0x76,0x00,0x00,0x00,
0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0x10,0x0c,0x00,0x00,0x00,
0x00,0x00,0x00,0x30,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x08,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x18,0xff,0x18,0x66,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7e,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x08,0x08,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x8e,0x9a,0xb2,0xa2,0xc2,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x08,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x7e,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0xc2,0x82,0x02,0x04,0x08,0x10,0x20,0x40,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x02,0x02,0x3c,0x02,0x02,0x02,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0x14,0x24,0x44,0x84,0x84,0xfe,0x04,0x04,0x1e,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x80,0x80,0x80,0xfc,0x02,0x02,0x02,0xc2,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x80,0x80,0xfc,0x82,0x82,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x82,0x82,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x82,0x7c,0x82,0x82,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x82,0x82,0x7e,0x02,0x02,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x08,0x08,0x10,0x00,
0x00,0x00,0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x02,0x04,0x08,0x08,0x00,0x08,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3c,0x42,0x9d,0xa5,0xa5,0xad,0xb6,0x40,0x3c,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0x42,0x42,0x42,0x7c,0x42,0x42,0x42,0x42,0xfc,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x80,0x80,0x80,0x80,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xfc,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x42,0x40,0x40,0x78,0x78,0x40,0x40,0x42,0xfe,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x42,0x40,0x48,0x78,0x48,0x40,0x40,0x40,0xf0,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x80,0x80,0x8e,0x82,0x82,0x82,0x7e,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x0e,0x04,0x04,0x04,0x04,0x04,0x84,0x84,0x84,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0xc2,0x42,0x42,0x42,0x44,0x78,0x44,0x42,0x42,0xc2,0x00,0x00,0x00,
0x00,0x00,0x00,0xf0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x42,0xfe,0x00,0x00,0x00,
0x00,0x00,0x00,0x81,0xc3,0xa5,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0xc2,0xa2,0x92,0x8a,0x86,0x82,0x82,0x82,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0x42,0x42,0x42,0x42,0x7c,0x40,0x40,0x40,0xf0,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x82,0x92,0x8a,0x7c,0x02,0x00,0x00,
0x00,0x00,0x00,0xfc,0x42,0x42,0x42,0x42,0x7c,0x44,0x44,0x42,0xe2,0x00,0x00,0x00,
0x00,0x00,0x00,0x7c,0x82,0x82,0x40,0x38,0x04,0x02,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0x92,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x42,0x24,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xa5,0x42,0x00,0x00,0x00,
0x00,0x00,0x00,0x81,0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81,0x81,0x00,0x00,0x00,
0x00,0x00,0x00,0x82,0x82,0x82,0x44,0x38,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0x81,0x01,0x02,0x04,0x08,0x10,0x20,0x41,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x3c,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x3c,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x3c,0x00,0x00,0x00,
0x00,0x00,0x00,0x10,0x28,0x44,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x00,
0x10,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x04,0x7c,0x84,0x84,0x84,0x8c,0x72,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0x40,0x40,0x7c,0x42,0x42,0x42,0x42,0x42,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x82,0x80,0x80,0x80,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x1c,0x04,0x04,0x7c,0x84,0x84,0x84,0x84,0x8c,0x76,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x82,0x82,0xfe,0x80,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x1c,0x22,0x20,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x84,0x84,0x84,0x84,0x84,0x7c,0x04,0x84,0x78,
0x00,0x00,0x00,0xc0,0x40,0x40,0x5c,0x66,0x42,0x42,0x42,0x42,0xc2,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x18,0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x06,0x00,0x0e,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x42,0x3c,
0x00,0x00,0x00,0xc0,0x40,0x40,0x42,0x44,0x48,0x78,0x44,0x42,0xc2,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xc3,0xa5,0x99,0x81,0x81,0x81,0x81,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x42,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x82,0x82,0x82,0x82,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xbc,0x42,0x42,0x42,0x42,0x42,0x7c,0x40,0x40,0xe0,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x84,0x84,0x84,0x84,0x84,0x7c,0x04,0x04,0x0e,
0x00,0x00,0x00,0x00,0x00,0x00,0xdc,0x62,0x40,0x40,0x40,0x40,0xe0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x82,0x60,0x18,0x04,0x82,0x7c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x10,0x7e,0x10,0x10,0x10,0x10,0x12,0x0c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x84,0x84,0x84,0x84,0x84,0x7a,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x81,0x81,0x81,0x81,0x42,0x24,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x81,0x81,0x81,0x81,0x99,0xa5,0xc3,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x81,0x42,0x24,0x18,0x24,0x42,0x81,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x6c,0x10,0x20,0x40,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x84,0x08,0x10,0x20,0x42,0xfe,0x00,0x00,0x00,
0x00,0x00,0x00,0x0e,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x0e,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x08,0x08,0x08,0x06,0x08,0x08,0x08,0x08,0x70,0x00,0x00,0x00,
0x00,0x00,0x72,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x28,0x44,0x82,0xfe,0x82,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x44,0x82,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x82,0x44,0x38,0x10,0x20,
0x00,0x00,0x24,0x24,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x42,0x3e,0x00,0x00,
0x0c,0x08,0x10,0x00,0x00,0x38,0x44,0x82,0x82,0xfe,0x80,0x82,0x44,0x38,0x00,0x00,
0x00,0x10,0x28,0x44,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0x00,
0x00,0x00,0x24,0x24,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0x00,
0x10,0x08,0x04,0x00,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0x00,
0x00,0x18,0x24,0x18,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x80,0x80,0x80,0x80,0x80,0x42,0x3c,0x08,0x10,
0x00,0x10,0x28,0x44,0x00,0x38,0x44,0x82,0x82,0xfe,0x80,0x82,0x44,0x38,0x00,0x00,
0x00,0x00,0x24,0x24,0x00,0x38,0x44,0x82,0x82,0xfe,0x80,0x82,0x44,0x38,0x00,0x00,
0x10,0x08,0x04,0x00,0x00,0x38,0x44,0x82,0x82,0xfe,0x80,0x82,0x44,0x38,0x00,0x00,
0x00,0x00,0x24,0x24,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x00,0x10,0x28,0x44,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x10,0x08,0x04,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x24,0x24,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,0x00,0x00,
0x00,0x38,0x44,0x38,0x44,0x82,0x82,0x82,0x82,0xfe,0x82,0x82,0x82,0x82,0x00,0x00,
0x0c,0x08,0x10,0xfe,0x80,0x80,0x80,0x80,0xf8,0x80,0x80,0x80,0x80,0xfe,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x1c,0x12,0x72,0x9e,0x90,0x90,0x92,0x6c,0x00,0x00,
0x0c,0x10,0x20,0x28,0x28,0x28,0xfe,0x28,0x28,0x28,0x28,0x28,0x28,0x28,0x00,0x00,
0x00,0x10,0x28,0x44,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x00,0x00,0x24,0x24,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x10,0x08,0x04,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x00,0x10,0x28,0x44,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x42,0x3e,0x00,0x00,
0x10,0x08,0x04,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x42,0x3e,0x00,0x00,
0x00,0x00,0x24,0x24,0x00,0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x10,0x20,0x20,0x40,
0x24,0x24,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x24,0x24,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x00,0x28,0x28,0x28,0x3c,0x6a,0xa8,0xa8,0xa8,0xa8,0xa8,0x6a,0x3c,0x28,0x28,0x28,
0x00,0x0c,0x12,0x20,0x20,0x20,0xfc,0x20,0x20,0x20,0x60,0xa0,0xb2,0x4c,0x00,0x00,
0x00,0x82,0x82,0x44,0x28,0x10,0xfe,0x10,0x10,0xfe,0x10,0x10,0x10,0x10,0x00,0x00,
0x00,0xe0,0x90,0x88,0x88,0x88,0x94,0xe4,0x9f,0x84,0x84,0x84,0x84,0x84,0x00,0x00,
0x00,0x0c,0x12,0x10,0x10,0x10,0xfe,0x10,0x10,0x10,0x10,0x10,0x90,0x60,0x00,0x00,
0x0c,0x08,0x10,0x00,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0x00,
0x0c,0x08,0x10,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x0c,0x08,0x10,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x0c,0x08,0x10,0x00,0x00,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x42,0x3e,0x00,0x00,
0x00,0x12,0x2a,0x24,0x00,0xf8,0x84,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x00,0x00,
0x12,0x2a,0x24,0x00,0x82,0xc2,0xc2,0xa2,0x92,0x92,0x8a,0x86,0x86,0x82,0x00,0x00,
0x00,0x00,0x00,0x78,0x04,0x04,0x3c,0x44,0x84,0x84,0x44,0x3e,0x00,0xfe,0x00,0x00,
0x00,0x00,0x00,0x38,0x44,0x82,0x82,0x82,0x82,0x82,0x44,0x38,0x00,0xfe,0x00,0x00,
0x00,0x10,0x10,0x00,0x00,0x10,0x10,0x20,0x44,0x82,0x82,0x82,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x02,0x02,0x02,0x00,0x00,
0x00,0x10,0x30,0x10,0x10,0x10,0x00,0xfe,0x00,0x78,0x04,0x38,0x40,0x7c,0x00,0x00,
0x00,0x10,0x30,0x10,0x10,0x10,0x00,0xfe,0x00,0x18,0x28,0x48,0x7c,0x08,0x00,0x00,
0x00,0x10,0x10,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x12,0x24,0x48,0x90,0x90,0x48,0x24,0x12,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x90,0x48,0x24,0x12,0x12,0x24,0x48,0x90,0x00,0x00,0x00,0x00,
0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0x44,
0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,
0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,0x77,0xdd,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf4,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x10,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf4,0x04,0xf4,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x04,0xf4,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf4,0x04,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xff,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0x10,0x1f,0x10,0x10,0x10,0x10,0x10,0x10,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x17,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x17,0x10,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x10,0x17,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf7,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xf7,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x17,0x10,0x17,0x14,0x14,0x14,0x14,0x14,0x14,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf7,0x00,0xf7,0x14,0x14,0x14,0x14,0x14,0x14,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1f,0x10,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x10,0x1f,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0xf7,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xff,0x10,0xff,0x10,0x10,0x10,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

View File

@ -1,6 +1,7 @@
#include "../include/printf.h" #include "../include/printf.h"
#include "../include/common.h" #include "../include/common.h"
#include "../include/graphics.h" #include "../include/graphics.h"
#include "../include/serial.h"
static int skip_atoi(const char **s) { static int skip_atoi(const char **s) {
int i = 0; int i = 0;
@ -320,3 +321,18 @@ void print(char *message) {
vbe_writestring(message); vbe_writestring(message);
} else vga_writestring(message); } else vga_writestring(message);
} }
void logkf(char *formet,...){
int len;
va_list ap;
va_start(ap, formet);
char *buf[1024] = {0};
len = vsprintf(buf, formet, ap);
logk(buf);
va_end(ap);
}
void logk(char *message){
for (size_t i = 0; i < strlen(message); i++)
write_serial(message[i]);
}