Skip to content

Commit

Permalink
v0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
sxysxy committed Aug 8, 2019
1 parent eabc778 commit c2e8012
Show file tree
Hide file tree
Showing 17 changed files with 1,612 additions and 28 deletions.
6 changes: 0 additions & 6 deletions TaurixFS/boot/grub/grub.cfg

This file was deleted.

15 changes: 7 additions & 8 deletions configure.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/ruby
#!/bin/ruby
#encoding: utf-8
# Generate makefile from settings for building taruix
# author: hfcloud(sxysxygm@gmail.com)
# date: 2019.07.28
Expand Down Expand Up @@ -151,19 +152,17 @@ def src_obj_file(file)
end

#制成由grub引导的硬盘镜像文件的规则
MAKEFILE.print("Taurix.img: Taurix\n\t")
MAKEFILE.print("cp Taurix ./TaurixFS/boot\n\t")
MAKEFILE.print("grub-mkrescue -o Taurix.img TaurixFS\n")
MAKEFILE.print("image/Taurix.img: Taurix\n\t")
MAKEFILE.print("ruby image/build_grub_booted.rb\n")

#别名 Image <-> Taurix.img
MAKEFILE.print("Image:\n\tmake Taurix.img\n")
MAKEFILE.print("Image:\n\tmake image/Taurix.img\n")

#清除规则
MAKEFILE.print("clean:\n\t")
MAKEFILE.print("#{RM} *.o\n\t")
MAKEFILE.print("#{RM} Taurix\n\t")
MAKEFILE.print("#{RM} Taurix.img\n\t")
MAKEFILE.print("#{RM} ./TaurixFS/boot/Taurix\n")
MAKEFILE.print("#{RM} image/Taurix.img\n")

MAKEFILE.close

Expand All @@ -172,7 +171,7 @@ def src_obj_file(file)
#!/usr/bin/sh
make Image
if [ $? -eq 0 ]; then
env LANG=en_US.UTF8 qemu-system-#{$arch} Taurix.img %s
env LANG=en_US.UTF8 qemu-system-#{$arch} image/Taurix.img %s
fi
AAAA

Expand Down
2 changes: 2 additions & 0 deletions image/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.img
ImageBuild.log
13 changes: 13 additions & 0 deletions image/Taurix.tfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/tfstools
open Taurix.img

# Select the EFI Partition
select 0

#copy grub.cfg and Taruix
enter_part FAT32
push ../Taurix Taurix
cd GRUB
push grub.cfg grub.cfg
close
exit 0
14 changes: 14 additions & 0 deletions image/build_grub_booted.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/ruby
#encoding: utf-8

require 'fileutils'
Dir.chdir(File.dirname(__FILE__))

FileUtils.cp("template.img", "Taurix.img")
if !system("tfstools Taurix.tfs > ImageBuild.log")
FileUtils.rm("Taurix.img")
puts("Failed to build Taurix.img")
exit 1
end


7 changes: 7 additions & 0 deletions image/grub.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
insmod part_gpt
insmod elf
insmod video_info

menuentry 'Taurix' --class os {
multiboot /Taurix
}
7 changes: 5 additions & 2 deletions include/taurix/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ int ru_sprintf_s(char *buf, size_t max_size, const char *format, ...); //->s

//stdlib.h
void *ru_memset(void *base, uint8 data, size_t size); //->src/utils/utils.c
void *ru_memcpy(void *dest, void *src, size_t size);
void *ru_memcpy(void *dest, const void *src, size_t size);

//string.h
char *ru_strcpy(char *dest, const char *src); //->src/utils/utils.c
int ru_strlen(const char *str);
int ru_strcmp(const char *a, const char *b);
int ru_strncmp(const char *a, const char *b, size_t size);
char *ru_strncpy(char *dest, const char *src, size_t size);
int ru_memcmp(const void *a, const void *b, size_t size);
char *ru_strcat(char *dest, const char *src);

//math
//整数开根,返回根号x下取整
Expand Down Expand Up @@ -109,7 +113,6 @@ int32 ru_detect_available_memory(size_t min_size, _OUT void **baseaddr, _OUT siz
int32 ru_text_init();
int32 ru_text_putchar(int ch); //->src/平台/arch_utils(n).c 平台相关的函数
void ru_text_print(const char *text);
int32 ru_text_printf(const char *format, ...);
void ru_text_set_color(uint32 color); //设置文本的颜色
void ru_text_set_cursor(int row, int col);
int32 ru_text_get_colmns(); //获得文本模式下文字的 列数(宽度)
Expand Down
4 changes: 2 additions & 2 deletions src/arch/i386/extra_flags.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_CC_FLAGS_COMMON.push("-m32")
_CXX_FLAGS_COMMON.push("-m32")
_CC_FLAGS_COMMON.push("-m32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast")
_CXX_FLAGS_COMMON.push("-m32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast")
_ASM_FLAGS_COMMON.push("-f elf")

if RUBY_PLATFORM =~ /darwin/ #fuck OSX CLANG
Expand Down
3 changes: 2 additions & 1 deletion src/arch/i386/i386_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void clock_int_handler(Context *context) {
}

//开始进行调度, 使用第一个加入调度器的进程作为第一个进程,duration_per_slice指定了每个时间片的时间(单位:ms)
int32 ps_schedule(ProcessScheduler *ps, uint32 duration_per_slice) {
int32 ps_schedule(ProcessScheduler *ps, uint32 duration_per_slice) {
ru_disable_interrupt();
//
uint16 freq = 1000 / duration_per_slice;
Expand Down Expand Up @@ -162,6 +162,7 @@ void ps_do_auto_schedule(ProcessScheduler *ps, Context *context) { //时间片
ru_memcpy(context, &perfer_proc->context, sizeof(Context));
else //同特权级任务切换,不需要恢复堆栈
ru_memcpy(context, &perfer_proc->context, sizeof(Context) - 8); //no esp0, ss0

} else { //依然没有进程可以调度,挂起
ru_text_set_color(VGA_TEXT_RED);
ru_text_print("[ Halt ] No process to switch\n");
Expand Down
Loading

0 comments on commit c2e8012

Please sign in to comment.