Skip to content

Commit

Permalink
cp3 handin
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifei Teng committed Nov 16, 2015
1 parent 1073ef1 commit fb0d9a6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 112 deletions.
105 changes: 0 additions & 105 deletions mp3/student-distrib/init/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,111 +16,6 @@ __attribute__((used)) void init_main()
{
printf("Hello!\nI am the idle process!\nI am a kernel process!\nI am every other process's parent!\n");

// ---- TEST REAL MODE ----

int32_t keyb = fs_open("/dev/keyb");
char buf[2];

printf("keyboard opened\n");

cli();

auto vbeInfoMaybe = getVbeInfo();
if(vbeInfoMaybe)
{
VbeInfo vbeInfo (!vbeInfoMaybe);
printf("VBE Information:\n");
if(vbeInfo.vbe2)
printf("\tSupports VBE 2.0\n");
if(vbeInfo.vbe3)
printf("\tSupports VBE 3.0\n");
printf("\tVbeCapability = %x\n", vbeInfo.capabilityFlags);
printf("\tOEM = %s\n", vbeInfo.oemString);
printf("\tTotal Memory = %d KB\n", ((uint32_t)(vbeInfo.totalMemory)) * 64);

printf("\tAvailable Video Modes:\n");
for(int i=0; vbeInfo.modeList[i]!=0xffff; i++)
{
uint16_t mode = vbeInfo.modeList[i];
printf("\t Mode %x: ", mode);

// Query more about this mode
auto modeInfoMaybe = getVideoModeInfo(mode);
if(modeInfoMaybe)
{
VideoModeInfo modeInfo(!modeInfoMaybe);
printf(" XRes=%d, YRes=%d, BaseAddr=%x, Color=%s\n",
modeInfo.xRes,
modeInfo.yRes,
modeInfo.physBase,
modeInfo.RGBMask);
}
else printf("\t\tCan't get any information\n");
}
printf("\n");
}

// Wait for user
sti();
fs_read(keyb, buf, 1);
cli();


//------------- Try to draw 1024 * 768 HD Graphics ----------------
auto Mode118Maybe = getVideoModeInfo(0x118);
if(Mode118Maybe) ;
else printf("1024*768 24bits mode is NOT supported.\n");
VideoModeInfo Mode118(!Mode118Maybe);
uint32_t Mode118Mem = Mode118.physBase;

uint16_t orig_mode;

// Back up current mode.
real_context_t real_context;
real_context.ax = 0x0f00;
legacyInt(0x10, real_context);
orig_mode = real_context.ax & 0x00ff;

LOAD_4MB_PAGE(Mode118Mem>>22, Mode118Mem, PG_WRITABLE);
RELOAD_CR3();
for(int i=0; i < 512 * 768; i++)
{
uint8_t* pixel = (uint8_t*)(Mode118Mem + i * 3);
pixel[0] = 0xff;
pixel[1] = 0xff;
pixel[2] = 0x0;
}
for(int i=512*768; i < 1024 * 768; i++)
{
uint8_t* pixel = (uint8_t*)(Mode118Mem + i * 3);
pixel[0] = 0;
pixel[1] = 0xff;
pixel[2] = 0xff;
}

// Change to HD Video Mode
real_context.ax=0x4F02;
real_context.bx=0x8118;
legacyInt(0x10, real_context);

// Wait for user
sti();
fs_read(keyb, buf, 1);
cli();

// Change back to original mode
real_context.ax=orig_mode;
legacyInt(0x10, real_context);

printf("Back to KERNEL!\n");

sti();

fs_close(keyb);


// ------------- Actual INIT starts here ---------------

/* Enable interrupts */
sti();

Expand Down
6 changes: 0 additions & 6 deletions mp3/student-distrib/syscalls/syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ using namespace boost;
using syscall_exec::sysexec;
using syscall_halt::syshalt;

// int32_t sysHalt(uint32_t p)
// {
// printf("Ooo.. Halt with %d\n", p);
// return 0;
// }

template<typename F>
F super_cast(uint32_t input)
{
Expand Down
2 changes: 1 addition & 1 deletion mp3/student-distrib/x86/real-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void legacyInt(int16_t interrupt_num, real_context_t& regs)
{
uint32_t flags;
spin_lock_irqsave(&legacyInt_lock, flags);

// Pass in the parameters.
*(int16_t*)(RealModePtr(REAL_MODE_DATA_BASE, 0).get32()) = interrupt_num;
*(real_context_t*)(RealModePtr(REAL_MODE_DATA_BASE, sizeof(int16_t)).get32()) = regs;
Expand Down

0 comments on commit fb0d9a6

Please sign in to comment.