Import backup from 2004-04-03
This commit is contained in:
parent
7110307896
commit
6236c341dd
6
Makefile
6
Makefile
@ -97,7 +97,7 @@ install_img:
|
|||||||
# Write the Stage 1 IPL to the boot sector #
|
# Write the Stage 1 IPL to the boot sector #
|
||||||
############################################
|
############################################
|
||||||
@echo "Writing boot sector to image..."
|
@echo "Writing boot sector to image..."
|
||||||
dd if=stage1.bin of=$(FLOPPY_IMAGE) seek=0
|
dd if=boot/stage1.bin of=$(FLOPPY_IMAGE) seek=0
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Copy the files onto the image #
|
# Copy the files onto the image #
|
||||||
@ -107,9 +107,9 @@ install_img:
|
|||||||
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
||||||
|
|
||||||
@echo "Copying stage 2 bootloader to the floppy image..."
|
@echo "Copying stage 2 bootloader to the floppy image..."
|
||||||
$(COPY_BIN) stage2.bin $(FLOPPY_MOUNT)
|
$(COPY_BIN) boot/stage2.bin $(FLOPPY_MOUNT)
|
||||||
@echo "Copying kernel to the floppy image..."
|
@echo "Copying kernel to the floppy image..."
|
||||||
$(COPY_BIN) kernel.bin $(FLOPPY_MOUNT)
|
$(COPY_BIN) kernel/kernel.bin $(FLOPPY_MOUNT)
|
||||||
|
|
||||||
@echo "Unmounting floppy image..."
|
@echo "Unmounting floppy image..."
|
||||||
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
mount $(FLOPPY_IMAGE) $(FLOPPY_MOUNT) -o loop
|
||||||
|
BIN
boot/stage1.bin
Normal file
BIN
boot/stage1.bin
Normal file
Binary file not shown.
BIN
boot/stage2.bin
Normal file
BIN
boot/stage2.bin
Normal file
Binary file not shown.
22
kernel/block/loop.c
Normal file
22
kernel/block/loop.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// loop.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/16/04
|
||||||
|
// Provides a loop-back device for mounting files on existing volumes as new volumes
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "loop.h"
|
||||||
|
#include "fs/vfs.h"
|
||||||
|
|
||||||
|
int loop_readSector(LoopDevice *ld, dword sector, byte *buffer)
|
||||||
|
{
|
||||||
|
return vfs_readFileBlock(ld->vol, ld->filePath, sector * LOOP_SECTOR_SIZE, buffer, LOOP_SECTOR_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int loop_writeSector(LoopDevice *ld, dword sector, byte *buffer)
|
||||||
|
{
|
||||||
|
return vfs_writeFileBlock(ld->vol, ld->filePath, sector * LOOP_SECTOR_SIZE, buffer, LOOP_SECTOR_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
22
kernel/block/loop.h
Normal file
22
kernel/block/loop.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// loop.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/16/04
|
||||||
|
// Provides a loop-back device for mounting files on existing volumes as new volumes
|
||||||
|
|
||||||
|
#ifndef __HOS_LOOP__
|
||||||
|
#define __HOS_LOOP__ __HOS_LOOP__
|
||||||
|
|
||||||
|
#include "hos_includes.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
Volume *vol;
|
||||||
|
char filePath[256];
|
||||||
|
} LoopDevice;
|
||||||
|
|
||||||
|
int loop_readSector(LoopDevice *ld, dword sector, byte *buffer);
|
||||||
|
int loop_writeSector(LoopDevice *ld, dword sector, byte *buffer);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
// fat12.c
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Date: 03/11/04
|
|
||||||
|
|
||||||
#include "fat12.h"
|
|
||||||
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
|||||||
// fat12.h
|
|
||||||
// Author: Josh Holtrop
|
|
||||||
// Date: 03/11/04
|
|
||||||
|
|
||||||
#ifndef __HOS_FAT12__
|
|
||||||
#define __HOS_FAT12__ __HOS_FAT12__
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
113
kernel/fs/vfat.c
Normal file
113
kernel/fs/vfat.c
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// vfat.c
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/11/04
|
||||||
|
// Modified: 03/22/04
|
||||||
|
|
||||||
|
#include "vfat.h"
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "fs/vfs.h"
|
||||||
|
#include "mm/vmm.h"
|
||||||
|
#include "string/string.h"
|
||||||
|
|
||||||
|
//From Microsoft's FAT32 File System Specification
|
||||||
|
DSKSZTOSECPERCLUS DskTableFAT16 [] =
|
||||||
|
{
|
||||||
|
{ 8400, 0}, /* disks up to 4.1 MB, the 0 value for SecPerClusVal trips an error */
|
||||||
|
{ 32680, 2}, /* disks up to 16 MB, 1k cluster */
|
||||||
|
{ 262144, 4}, /* disks up to 128 MB, 2k cluster */
|
||||||
|
{ 524288, 8}, /* disks up to 256 MB, 4k cluster */
|
||||||
|
{ 1048576, 16}, /* disks up to 512 MB, 8k cluster */
|
||||||
|
/* The entries after this point are not used unless FAT16 is forced */
|
||||||
|
// { 2097152, 32}, /* disks up to 1 GB, 16k cluster */
|
||||||
|
// { 4194304, 64}, /* disks up to 2 GB, 32k cluster */
|
||||||
|
{ 0xFFFFFFFF, 0} /* any disk greater than 2GB, 0 value for SecPerClusVal trips an error */
|
||||||
|
};
|
||||||
|
|
||||||
|
//From Microsoft's FAT32 File System Specification
|
||||||
|
DSKSZTOSECPERCLUS DskTableFAT32 [] =
|
||||||
|
{
|
||||||
|
{ 66600, 0}, /* disks up to 32.5 MB, the 0 value for SecPerClusVal trips an error */
|
||||||
|
{ 532480, 1}, /* disks up to 260 MB, .5k cluster */
|
||||||
|
{ 16777216, 8}, /* disks up to 8 GB, 4k cluster */
|
||||||
|
{ 33554432, 16}, /* disks up to 16 GB, 8k cluster */
|
||||||
|
{ 67108864, 32}, /* disks up to 32 GB, 16k cluster */
|
||||||
|
{ 0xFFFFFFFF, 64}/* disks greater than 32GB, 32k cluster */
|
||||||
|
};
|
||||||
|
|
||||||
|
int vfat_identify(vfat_bpb *bpb)
|
||||||
|
{
|
||||||
|
int rootDirSectors = ((bpb->rootEntries * 32) + (bpb->bytesPerSector - 1)) / bpb->bytesPerSector;
|
||||||
|
int totalSectors = bpb->totalSectors16 ? bpb->totalSectors16 : bpb->totalSectors32;
|
||||||
|
int fatSectors = bpb->sectorsPerFAT16 ? bpb->sectorsPerFAT16 : bpb->sectorsPerFAT32;
|
||||||
|
int dataSectors = totalSectors - (bpb->reservedSectors + bpb->numFATs * fatSectors + rootDirSectors);
|
||||||
|
int clusters = dataSectors / bpb->sectorsPerCluster;
|
||||||
|
if (clusters < 4085)
|
||||||
|
return 12;
|
||||||
|
if (clusters < 65525)
|
||||||
|
return 16;
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int vfat_format(Volume *vol)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *vfat_open(char *fileName, dword attributes, Volume *vol)
|
||||||
|
{
|
||||||
|
while (*fileName == '/')
|
||||||
|
++fileName;
|
||||||
|
if (strlen(fileName) < 1)
|
||||||
|
return 0;
|
||||||
|
vfat_bpb *bpb = vfat_getBootSector(vol);
|
||||||
|
if (!bpb) return 0;
|
||||||
|
byte *fat = vfat_loadFAT(vol, bpb);
|
||||||
|
if (!fat)
|
||||||
|
{
|
||||||
|
free(bpb);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int segs = string_split(fileName); //number of sections of path (1=file is in root directory)
|
||||||
|
int me = vfat_identify(bpb);
|
||||||
|
if (me != 32)
|
||||||
|
{
|
||||||
|
if (segs == 1) //we are looking for the file in the root directory
|
||||||
|
{
|
||||||
|
vfat_getEntryInRoot(vol, bpb, fileName, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
byte *vfat_loadFAT(Volume *vol, vfat_bpb *bpb)
|
||||||
|
{
|
||||||
|
int fatSize = bpb->sectorsPerFAT16 ? bpb->sectorsPerFAT16 : bpb->sectorsPerFAT32;
|
||||||
|
byte *fat = malloc(fatSize << 9); //512 bytes per sector
|
||||||
|
if (!fat) return 0;
|
||||||
|
if (vfs_readSectorn(vol, bpb->reservedSectors, fat, fatSize))
|
||||||
|
{
|
||||||
|
free(fat);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return fat;
|
||||||
|
}
|
||||||
|
|
||||||
|
vfat_bpb *vfat_getBootSector(Volume *vol)
|
||||||
|
{
|
||||||
|
vfat_bpb *bs;
|
||||||
|
if (!(bs = malloc(512)))
|
||||||
|
return 0;
|
||||||
|
vfs_readSector(vol, 0, bs);
|
||||||
|
return bs;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfat_close(FILE *fp)
|
||||||
|
{
|
||||||
|
return free(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
135
kernel/fs/vfat.h
Normal file
135
kernel/fs/vfat.h
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
// vfat.h
|
||||||
|
// Author: Josh Holtrop
|
||||||
|
// Date: 03/11/04
|
||||||
|
// Modified: 03/22/04
|
||||||
|
|
||||||
|
#ifndef __HOS_VFAT__
|
||||||
|
#define __HOS_VFAT__ __HOS_VFAT__
|
||||||
|
|
||||||
|
#include "hos_defines.h"
|
||||||
|
#include "fs/vfs.h"
|
||||||
|
|
||||||
|
#define VFAT_FAT12_EOCL 0x0FF8 // end-of-cluster chain reached if FatValue >= EOCL
|
||||||
|
#define VFAT_FAT16_EOCL 0xFFF8
|
||||||
|
#define VFAT_FAT32_EOCL 0x0FFFFFF8
|
||||||
|
|
||||||
|
#define VFAT_FAT12_EOC 0x0FFF // end-of-cluster chain value
|
||||||
|
#define VFAT_FAT16_EOC 0xFFFF
|
||||||
|
#define VFAT_FAT32_EOC 0x0FFFFFFF
|
||||||
|
|
||||||
|
#define VFAT_FAT12_BAD 0x0FF7 // bad cluster mark
|
||||||
|
#define VFAT_FAT16_BAD 0xFFF7
|
||||||
|
#define VFAT_FAT32_BAD 0x0FFFFFF7
|
||||||
|
|
||||||
|
#define VFAT_DIRENTRY_FREE 0xE5
|
||||||
|
#define VFAT_DIRENTRY_FREE_LAST 0x00
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
byte jmpBoot[3]; // {0xEB, 0x??, 0x90} or {0xE9, 0x??, 0x??}
|
||||||
|
char OEMName[8]; // any 8-char string (def. "MSWIN4.1")
|
||||||
|
word bytesPerSector; // 512 (default), 1024, 2048, 4096
|
||||||
|
byte sectorsPerCluster; // 1 (default), 2, 4, 8, 16, 32, 64, 128
|
||||||
|
word reservedSectors; // 1 (fat12/16), 32 (fat32)
|
||||||
|
byte numFATs; // 2
|
||||||
|
word rootEntries; // number of 32-byte root directory entries (224 for 1440k floppy) - 0 for fat32
|
||||||
|
word totalSectors16; // total number of sectors in volume (2880 for floppy) - 0 for fat32
|
||||||
|
byte media; // >= 0xF0 valid, 0xF8 (default non-removable), 0xF0 (default removable), must match lsb of FAT[0]
|
||||||
|
word sectorsPerFAT16; // number of sectors in FAT (9 for floppy)
|
||||||
|
word sectorsPerTrack; // (18 for floppy)
|
||||||
|
word numHeads; // number of heads (2 for floppy)
|
||||||
|
dword hiddenSectors; // 0
|
||||||
|
dword totalSectors32; // 0, non-zero for fat32 volumes
|
||||||
|
|
||||||
|
/* FAT32 specific members */
|
||||||
|
dword sectorsPerFAT32; // number of sectors in a fat for fat32 volumes
|
||||||
|
word extFlags; // bits 0-3 active fat, bit 7 {0 = mirror all FATs, 1 = only use 1 FAT}
|
||||||
|
word fsVersion; // fat32 version (0:0)
|
||||||
|
dword rootCluster; // first cluster of root directory (default 2)
|
||||||
|
word fsInfo; // sector number of FSINFO block (default 1)
|
||||||
|
word bootCopy; // sector of backup boot record (default 6)
|
||||||
|
} __attribute__ ((packed)) vfat_bpb;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
dword leadSignature; // 0x41615252
|
||||||
|
byte reserved1[480];
|
||||||
|
dword structSignature; // 0x61417272
|
||||||
|
dword lastFree; // last known free cluster (0xFFFFFFFF == unknown)
|
||||||
|
dword nextFree; // start looking for free clusters here (0xFFFFFFFF == unknown)
|
||||||
|
byte reserved2[12];
|
||||||
|
dword trailSignature; // 0xAA550000
|
||||||
|
} __attribute__ ((packed)) vfat_fsinfo;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char fileName[8]; // file name, 8 char. max, pad w/ spaces
|
||||||
|
char fileExt[3]; // file extension, 3 char. max, pad w/ spaces
|
||||||
|
byte attributes; // file attributes, read-only, etc.
|
||||||
|
byte reserved; // 0
|
||||||
|
byte timeTenths; // 0-199
|
||||||
|
word time; // time of creation
|
||||||
|
word date; // date of creation
|
||||||
|
word adate; // last accessed date
|
||||||
|
word clusterHigh; // 0 for fat12/16
|
||||||
|
word wtime; // last write time
|
||||||
|
word wdate; // last write date
|
||||||
|
word clusterLow; // LSW of first cluster of file data
|
||||||
|
dword fileSize;
|
||||||
|
} __attribute__ ((packed)) vfat_dirEntry;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
byte order;
|
||||||
|
word name0_4[5]; // filename - first 5 characters (unicode)
|
||||||
|
byte attributes; // must be VFAT_LONG_NAME
|
||||||
|
byte type; // 0 = part of long name
|
||||||
|
byte checksum; // checksum of short entry at end of long entry set
|
||||||
|
word name5_10[6]; // filename - next 6 characters (unicode)
|
||||||
|
word clusterLow; // 0
|
||||||
|
word name11_12[2]; // filename - next 2 characters
|
||||||
|
} __attribute__ ((packed)) vfat_lfnEntry;
|
||||||
|
|
||||||
|
#define VFAT_READ_ONLY 0x01
|
||||||
|
#define VFAT_HIDDEN 0x02
|
||||||
|
#define VFAT_SYSTEM 0x04
|
||||||
|
#define VFAT_VOLUME 0x08
|
||||||
|
#define VFAT_DIRECTORY 0x10
|
||||||
|
#define VFAT_ARCHIVE 0x20
|
||||||
|
|
||||||
|
#define VFAT_LONG_NAME 0x0F // VFAT_READ_ONLY | VFAT_HIDDEN | VFAT_SYSTEM | VFAT_VOLUME
|
||||||
|
#define VFAT_ATTR_MASK 0x3F // VFAT_READ_ONLY | VFAT_HIDDEN | VFAT_SYSTEM | VFAT_VOLUME | VFAT_DIRECTORY | VFAT_ARCHIVE
|
||||||
|
|
||||||
|
#define VFAT_ORDER_MASK 0x40
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Illegal file name characters:
|
||||||
|
* Values less than 0x20 except for 0x05. 0x05 signifies that the actual filename character is 0xE5
|
||||||
|
* 0x22 ("), 0x2A (*)
|
||||||
|
* 0x2E (.), 0x2F (/), 0x3A (:)
|
||||||
|
* 0x3C (<), 0x3E (>), 0x3F (?), 0x5C (\), 0x7C (|)
|
||||||
|
* The following are illegal in 8.3 but legal in LFN:
|
||||||
|
* 0x2B (+), 0x2C (,), 0x3B (;), 0x3D (=), 0x5B ([), 0x5D (])
|
||||||
|
*/
|
||||||
|
|
||||||
|
//From Microsoft's FAT32 File System Specification
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
dword diskSize;
|
||||||
|
byte sectorsPerCluster;
|
||||||
|
} DSKSZTOSECPERCLUS;
|
||||||
|
|
||||||
|
// sector[510] == 0x55
|
||||||
|
// sector[511] == 0xAA
|
||||||
|
|
||||||
|
int vfat_identify(vfat_bpb *bpb);
|
||||||
|
int vfat_format(Volume *vol);
|
||||||
|
FILE *vfat_open(char *fileName, dword attributes, Volume *vol);
|
||||||
|
vfat_bpb *vfat_getBootSector(Volume *vol);
|
||||||
|
int vfat_close(FILE *fp);
|
||||||
|
byte *vfat_loadFAT(Volume *vol, vfat_bpb *bpb)
|
||||||
|
vfat_getEntryInRoot(vol, bpb, fileName, 0);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
|||||||
// vfs.c
|
// vfs.c
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 03/11/04
|
// Date: 03/11/04
|
||||||
|
// Modified: 03/16/04
|
||||||
|
|
||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
|
#include "fs/vfat.h"
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
#include "block/rd.h"
|
||||||
|
#include "block/loop.h"
|
||||||
|
|
||||||
Volume *firstVolume = 0;
|
Volume *firstVolume = 0;
|
||||||
Volume *rootVolume = 0;
|
Volume *rootVolume = 0;
|
||||||
@ -39,4 +43,73 @@ Volume *vfs_getLastVolume()
|
|||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vfs_readSector(Volume *vol, dword sector, byte *buffer)
|
||||||
|
{
|
||||||
|
switch(vol->deviceType)
|
||||||
|
{
|
||||||
|
case VFS_RD:
|
||||||
|
return rd_readSector(vol->diskDevice, sector, buffer);
|
||||||
|
case VFS_LOOP:
|
||||||
|
return loop_readSector(vol->diskDevice, sector, buffer);
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfs_writeSector(Volume *vol, dword sector, byte *buffer)
|
||||||
|
{
|
||||||
|
switch(vol->deviceType)
|
||||||
|
{
|
||||||
|
case VFS_RD:
|
||||||
|
return rd_writeSector(vol->diskDevice, sector, buffer);
|
||||||
|
case VFS_LOOP:
|
||||||
|
return loop_writeSector(vol->diskDevice, sector, buffer);
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfs_readSectorn(Volume *vol, dword sector, byte *buffer, int n)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
for (; n > 0; --n, ++sector, buffer += 512)
|
||||||
|
{
|
||||||
|
r = vfs_readSector(vol, sector, buffer);
|
||||||
|
if (r) return r;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfs_writeSectorn(Volume *vol, dword sector, byte *buffer, int n)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
for (; n > 0; --n, ++sector, buffer += 512)
|
||||||
|
{
|
||||||
|
r = vfs_writeSector(vol, sector, buffer);
|
||||||
|
if (r) return r;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vfs_readFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize)
|
||||||
|
{
|
||||||
|
switch(vol->fsType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int vfs_writeFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize)
|
||||||
|
{
|
||||||
|
switch(vol->fsType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,25 +1,51 @@
|
|||||||
// vfs.h
|
// vfs.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 03/11/04
|
// Date: 03/11/04
|
||||||
|
// Modified: 03/16/04
|
||||||
|
|
||||||
#ifndef __HOS_VFS__
|
#ifndef __HOS_VFS__
|
||||||
#define __HOS_VFS__ __HOS_VFS__
|
#define __HOS_VFS__ __HOS_VFS__
|
||||||
|
|
||||||
#include "hos_defines.h"
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
#define VFS_LABEL_LENGTH 8
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
void *diskDevice;
|
void *diskDevice; //pointer to device-dependent structure
|
||||||
int deviceType;
|
int length; //size of the volume in bytes
|
||||||
char label[12];
|
int deviceType; //one of VFS_DISK_TYPES
|
||||||
void *link;
|
int fsType; //one of VFS_FS_TYPES
|
||||||
|
char label[VFS_LABEL_LENGTH]; //descriptive volume label
|
||||||
|
void *link; //link to next volume in linked list
|
||||||
} Volume;
|
} Volume;
|
||||||
|
|
||||||
enum VFS_DISK_TYPES {VFS_RD, VFS_FD, VFS_HD, VFS_NUM_DISK_TYPES};
|
typedef struct
|
||||||
|
{
|
||||||
|
dword location; //location used by disk driver
|
||||||
|
dword dataLocation; //location used by disk driver
|
||||||
|
dword position; //read/write position in file
|
||||||
|
dword attributes; //read/write
|
||||||
|
dword fileSize; //number of bytes the file takes
|
||||||
|
Volume *vol; //what volume this file is on
|
||||||
|
} FILE;
|
||||||
|
|
||||||
|
#define FILE_READ 1
|
||||||
|
#define FILE_WRITE 2
|
||||||
|
#define FILE_READ_WRITE 3
|
||||||
|
|
||||||
|
enum VFS_DISK_TYPES {VFS_NODISK, VFS_RD, VFS_FD, VFS_HD, VFS_LOOP, VFS_NUM_DISK_TYPES};
|
||||||
|
enum VFS_FS_TYPES {VFS_NOFS, VFS_VFAT, VFS_EXT2, VFS_NUM_FS_TYPES};
|
||||||
|
|
||||||
void vfs_init();
|
void vfs_init();
|
||||||
Volume *vfs_newVolume();
|
Volume *vfs_newVolume();
|
||||||
Volume *vfs_getLastVolume();
|
Volume *vfs_getLastVolume();
|
||||||
|
int vfs_readSector(Volume *vol, dword sector, byte *buffer);
|
||||||
|
int vfs_writeSector(Volume *vol, dword sector, byte *buffer);
|
||||||
|
int vfs_readSectorn(Volume *vol, dword sector, byte *buffer, int n);
|
||||||
|
int vfs_writeSectorn(Volume *vol, dword sector, byte *buffer, int n);
|
||||||
|
int vfs_readFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
|
||||||
|
int vfs_writeFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static inline void timer_init()
|
|||||||
// - this should be the size of kernel.bin
|
// - this should be the size of kernel.bin
|
||||||
static inline dword kernel_size()
|
static inline dword kernel_size()
|
||||||
{
|
{
|
||||||
return (dword)(&_bss)-(dword)(&_code);
|
return (dword)(&_end)-(dword)(&_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
//converts a binary-coded-decimal byte to its decimal equivalent
|
//converts a binary-coded-decimal byte to its decimal equivalent
|
||||||
|
BIN
kernel/kernel.bin
Normal file
BIN
kernel/kernel.bin
Normal file
Binary file not shown.
@ -45,13 +45,22 @@ void k_init()
|
|||||||
kbd_resetLEDs(); //after enabling interrupts!!
|
kbd_resetLEDs(); //after enabling interrupts!!
|
||||||
if (video_Mode())
|
if (video_Mode())
|
||||||
{
|
{
|
||||||
int p = video_getWidth()*video_getHeight()-1;
|
int w = video_getWidth(), h = video_getHeight();
|
||||||
|
int p = w * h - 1;
|
||||||
for (; p >= 0; p--)
|
for (; p >= 0; p--)
|
||||||
video_pseti(p, 0x00000075);
|
video_pseti(p, 0x00000075);
|
||||||
|
int x = w >> 1, y = h >> 1, sz = h >> 1;
|
||||||
|
for (p = 0; p <= sz; p += 24)
|
||||||
|
{
|
||||||
|
video_line(x + p, y, x, y + sz - p, 0x0000FF00);
|
||||||
|
video_line(x + p, y, x, y - sz + p, 0x0000FF00);
|
||||||
|
video_line(x - p, y, x, y + sz - p, 0x0000FF00);
|
||||||
|
video_line(x - p, y, x, y - sz + p, 0x0000FF00);
|
||||||
|
}
|
||||||
kio_drawConsole();
|
kio_drawConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("HOS 0.14 - Kernel File Size: %u kb\tData Size: %u bytes\n", kernel_size()>>10, (dword)(&_end)-(dword)(&_code));
|
printf("HOS 0.14 - Kernel File Size: %u kb\n", kernel_size()>>10);
|
||||||
printf("Memory available to OS: %u MB (%u bytes)\n", mm_getTotalMegs(), mm_getTotalMem());
|
printf("Memory available to OS: %u MB (%u bytes)\n", mm_getTotalMegs(), mm_getTotalMem());
|
||||||
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
printf("Free memory: %u bytes (%u pages)\n", mm_freemem(), mm_freemem()>>12);
|
||||||
printf("%b/%b/%b\t%b:%b:%b\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
printf("%b/%b/%b\t%b:%b:%b\n", rtc_readMonth(), rtc_readDay(), rtc_readYear(), rtc_readHour(), rtc_readMinute(), rtc_readSecond());
|
||||||
|
18
kernel/kio.c
18
kernel/kio.c
@ -169,14 +169,24 @@ void kio_console_cls()
|
|||||||
// This function draws a simple "console" window in graphical mode to display text
|
// This function draws a simple "console" window in graphical mode to display text
|
||||||
void kio_drawConsole()
|
void kio_drawConsole()
|
||||||
{
|
{
|
||||||
video_rectf(9, 9, 490, 260, 0);
|
video_rectf(8, 8, 491, 261, 0);
|
||||||
video_rect(8, 8, 491, 261, 0x00777777);
|
video_rect(7, 7, 492, 262, 0x00777777);
|
||||||
int x, y;
|
int x, y;
|
||||||
|
x = 240, y = 125;
|
||||||
|
int s = 100, p = 0;
|
||||||
|
for (p = 0; p <= s; p += 16)
|
||||||
|
{
|
||||||
|
video_line(x + p, y, x, y + s - p, 0x00008800);
|
||||||
|
video_line(x + p, y, x, y - s + p, 0x00008800);
|
||||||
|
video_line(x - p, y, x, y + s - p, 0x00008800);
|
||||||
|
video_line(x - p, y, x, y - s + p, 0x00008800);
|
||||||
|
}
|
||||||
|
|
||||||
for (x = 0; x < 80; x++)
|
for (x = 0; x < 80; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < 25; y++)
|
for (y = 0; y < 25; y++)
|
||||||
{
|
{
|
||||||
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0, 0x0000FF00);
|
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0, 0x00FF9900);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +197,7 @@ void kio_drawConsoleChar(dword position)
|
|||||||
{
|
{
|
||||||
int x = position % 80;
|
int x = position % 80;
|
||||||
int y = position / 80;
|
int y = position / 80;
|
||||||
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0, 0x0000FF00);
|
video_renderChar(x*6+10, y*10+10, console_memory[y*80+x], 0, 0x00FF9900);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
276
kernel/lst/LDout.doc
Normal file
276
kernel/lst/LDout.doc
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
|
||||||
|
Allocating common symbols
|
||||||
|
Common symbol size file
|
||||||
|
|
||||||
|
_mouse_y 0x4 mouse.o
|
||||||
|
_video_mode 0x100 video.o
|
||||||
|
_console_memory 0xfa0 kio.o
|
||||||
|
_page_bitmap 0x20000 mm.o
|
||||||
|
_kbdBuffer 0x100 keyboard.o
|
||||||
|
_mouse_x 0x4 mouse.o
|
||||||
|
_mouse_inbuffer 0x10 mouse.o
|
||||||
|
|
||||||
|
Memory Configuration
|
||||||
|
|
||||||
|
Name Origin Length Attributes
|
||||||
|
*default* 0x0000000000000000 0xffffffffffffffff
|
||||||
|
|
||||||
|
Linker script and memory map
|
||||||
|
|
||||||
|
|
||||||
|
.text 0x00000000c0106000 0x4000
|
||||||
|
0x00000000c0106000 code = .
|
||||||
|
0x00000000c0106000 _code = .
|
||||||
|
0x00000000c0106000 __code = .
|
||||||
|
*(.text)
|
||||||
|
.text 0x00000000c0106000 0x384 ks.o
|
||||||
|
0x00000000c0106000 _start
|
||||||
|
.text 0x00000000c0106384 0x552 kernel.o
|
||||||
|
0x00000000c0106384 _k_init
|
||||||
|
0x00000000c010664d _draw_star
|
||||||
|
0x00000000c0106727 _isr
|
||||||
|
0x00000000c010655b _star_array
|
||||||
|
*fill* 0x00000000c01068d6 0x2 00
|
||||||
|
.text 0x00000000c01068d8 0x308 asmfuncs.o
|
||||||
|
0x00000000c01068f6 _read_cr3
|
||||||
|
0x00000000c01068fa _strcmp
|
||||||
|
0x00000000c0106a09 _puts
|
||||||
|
0x00000000c0106990 _memsetd
|
||||||
|
0x00000000c01069be _invlpg_
|
||||||
|
0x00000000c0106a28 _putDecu
|
||||||
|
0x00000000c010694c _memcpyd
|
||||||
|
0x00000000c0106935 _memcpy
|
||||||
|
0x00000000c0106963 _memset
|
||||||
|
0x00000000c01068f2 _read_cr2
|
||||||
|
0x00000000c01069c6 _writeCursorPosition
|
||||||
|
0x00000000c0106979 _memsetw
|
||||||
|
0x00000000c0106af0 _putDec
|
||||||
|
0x00000000c0106920 _strcpy
|
||||||
|
0x00000000c01069a6 _strlen
|
||||||
|
0x00000000c01069ec _getCursorPosition
|
||||||
|
0x00000000c01068d8 _write_cr0
|
||||||
|
0x00000000c01068e7 _write_cr3
|
||||||
|
0x00000000c01068e3 _read_cr0
|
||||||
|
.text 0x00000000c0106be0 0x693 keyboard.o
|
||||||
|
0x00000000c0107113 _kbdGetKey
|
||||||
|
0x00000000c01071a7 _kbd_resetLEDs
|
||||||
|
0x00000000c0106be0 _isr_keyboard
|
||||||
|
0x00000000c0107164 _kbdWaitKey
|
||||||
|
*fill* 0x00000000c0107273 0x1 00
|
||||||
|
.text 0x00000000c0107274 0x5f9 kio.o
|
||||||
|
0x00000000c01077ed _kio_drawConsoleChar
|
||||||
|
0x00000000c01073b0 _putc
|
||||||
|
0x00000000c01075f9 _kio_console_cls
|
||||||
|
0x00000000c01074ec _putHex
|
||||||
|
0x00000000c0107596 _kio_console_scroll
|
||||||
|
0x00000000c0107652 _kio_drawConsole
|
||||||
|
0x00000000c0107274 _printf
|
||||||
|
0x00000000c010755f _kio_putBCD
|
||||||
|
*fill* 0x00000000c010786d 0x3 00
|
||||||
|
.text 0x00000000c0107870 0x347 mm.o
|
||||||
|
0x00000000c0107a9b _mm_palloc
|
||||||
|
0x00000000c0107a51 _mm_pfree
|
||||||
|
0x00000000c0107a14 _mm_pfreen
|
||||||
|
0x00000000c0107870 _mm_init
|
||||||
|
0x00000000c0107b3f _mm_freemem
|
||||||
|
0x00000000c0107bad _mm_getTotalMegs
|
||||||
|
0x00000000c0107ba3 _mm_getTotalMem
|
||||||
|
*fill* 0x00000000c0107bb7 0x1 00
|
||||||
|
.text 0x00000000c0107bb8 0x1f5 mouse.o
|
||||||
|
0x00000000c0107bb8 _mouse_init
|
||||||
|
0x00000000c0107c58 _isr_mouse
|
||||||
|
*fill* 0x00000000c0107dad 0x3 00
|
||||||
|
.text 0x00000000c0107db0 0x8d stdfont.o
|
||||||
|
0x00000000c0107db0 _stdfont_getFontWidth
|
||||||
|
0x00000000c0107ddf _stdfont_getFontHeight
|
||||||
|
0x00000000c0107e0e _stdfont_getBitmap
|
||||||
|
*fill* 0x00000000c0107e3d 0x3 00
|
||||||
|
.text 0x00000000c0107e40 0x5cf video.o
|
||||||
|
0x00000000c0108289 _video_psetp32
|
||||||
|
0x00000000c0107ec9 _video_renderChar
|
||||||
|
0x00000000c01082d8 _video_getPhysBasePtr
|
||||||
|
0x00000000c01081ad _video_rectf
|
||||||
|
0x00000000c0108083 _video_pseti
|
||||||
|
0x00000000c0107e40 _video_init
|
||||||
|
0x00000000c01081f5 _video_psetp16
|
||||||
|
0x00000000c0107f85 _video_horiz
|
||||||
|
0x00000000c01082ec _video_line
|
||||||
|
0x00000000c010823b _video_psetp24
|
||||||
|
0x00000000c01082a4 _video_psetpnull
|
||||||
|
0x00000000c0108155 _video_rect
|
||||||
|
0x00000000c01082c9 _video_getBitsPerPixel
|
||||||
|
0x00000000c010809e _video_vert
|
||||||
|
0x00000000c01082a9 _video_getWidth
|
||||||
|
0x00000000c01082b9 _video_getHeight
|
||||||
|
0x00000000c01082e2 _video_Mode
|
||||||
|
0x00000000c010802c _video_pset
|
||||||
|
*fill* 0x00000000c010840f 0x1 00
|
||||||
|
.text 0x00000000c0108410 0x833 vmm.o
|
||||||
|
0x00000000c0108a17 _vmm_addHeapEntryBlock
|
||||||
|
0x00000000c0108bbe _free
|
||||||
|
0x00000000c01086ed _vmm_unmapn
|
||||||
|
0x00000000c01086ac _vmm_unmap1
|
||||||
|
0x00000000c0108b08 _vmm_getFirstHoleHeapEntry
|
||||||
|
0x00000000c01089fb _vmm_nextHeapEntry
|
||||||
|
0x00000000c010859e _vmm_map1
|
||||||
|
0x00000000c010883a _vmm_coalesceHeapEntry
|
||||||
|
0x00000000c0108904 _vmm_moreCore
|
||||||
|
0x00000000c0108410 _vmm_init
|
||||||
|
0x00000000c010871a _malloc
|
||||||
|
0x00000000c0108b87 _vmm_heapEntriesLeft
|
||||||
|
0x00000000c0108ad9 _vmm_getLastHeapEntry
|
||||||
|
0x00000000c0108c08 _vmm_getHeapEntryByBase
|
||||||
|
0x00000000c0108523 _vmm_heb_init
|
||||||
|
0x00000000c010878d _vmm_getFreeChunk
|
||||||
|
0x00000000c0108b4d _vmm_getFirstUnusedHeapEntry
|
||||||
|
0x00000000c0108673 _vmm_mapn
|
||||||
|
*fill* 0x00000000c0108c43 0x1 00
|
||||||
|
.text 0x00000000c0108c44 0x25c rtc.o
|
||||||
|
0x00000000c0108d3a _rtc_setDay
|
||||||
|
0x00000000c0108e39 _rtc_setHour
|
||||||
|
0x00000000c0108ce8 _rtc_readMinute
|
||||||
|
0x00000000c0108c96 _rtc_readYear
|
||||||
|
0x00000000c0108c44 _rtc_readDay
|
||||||
|
0x00000000c0108d6d _rtc_setMonth
|
||||||
|
0x00000000c0108d11 _rtc_readHour
|
||||||
|
0x00000000c0108cbf _rtc_readSecond
|
||||||
|
0x00000000c0108da0 _rtc_setYear
|
||||||
|
0x00000000c0108dd3 _rtc_setSecond
|
||||||
|
0x00000000c0108e06 _rtc_setMinute
|
||||||
|
0x00000000c0108c6d _rtc_readMonth
|
||||||
|
.text 0x00000000c0108ea0 0x120 pic.o
|
||||||
|
0x00000000c0108ea0 _pic_remap
|
||||||
|
.text 0x00000000c0108fc0 0x159 string.o
|
||||||
|
0x00000000c0108fc0 _strcat
|
||||||
|
0x00000000c0108fe8 _string_split
|
||||||
|
0x00000000c0109045 _string_advance
|
||||||
|
0x00000000c010909f _ucase
|
||||||
|
0x00000000c010905e _rtrim
|
||||||
|
0x00000000c01090dc _lcase
|
||||||
|
*fill* 0x00000000c0109119 0x3 00
|
||||||
|
.text 0x00000000c010911c 0xe4 cmos.o
|
||||||
|
0x00000000c0109174 _cmos_gethd0
|
||||||
|
0x00000000c010911c _cmos_getfd0
|
||||||
|
0x00000000c01091a0 _cmos_gethd1
|
||||||
|
0x00000000c0109148 _cmos_getfd1
|
||||||
|
0x00000000c010a000 . = ALIGN (0x1000)
|
||||||
|
*fill* 0x00000000c0109200 0x80b930000000e00 00
|
||||||
|
|
||||||
|
.data 0x00000000c010a000 0x1000
|
||||||
|
0x00000000c010a000 data = .
|
||||||
|
0x00000000c010a000 _data = .
|
||||||
|
0x00000000c010a000 __data = .
|
||||||
|
*(.data)
|
||||||
|
.data 0x00000000c010a000 0x18 stdfont.o
|
||||||
|
0x00000000c010a000 _fonts
|
||||||
|
.data 0x00000000c010a018 0x10 video.o
|
||||||
|
0x00000000c010a018 _vid_ptr16
|
||||||
|
0x00000000c010a024 _video_psetp
|
||||||
|
0x00000000c010a020 _vid_ptr32
|
||||||
|
0x00000000c010a01c _vid_ptr24
|
||||||
|
.data 0x00000000c010a028 0x4 vmm.o
|
||||||
|
0x00000000c010a028 _firstHeapEntry
|
||||||
|
0x00000000c010b000 . = ALIGN (0x1000)
|
||||||
|
*fill* 0x00000000c010a02c 0x80b941400000fd4 00
|
||||||
|
|
||||||
|
.bss 0x00000000c010b000 0x221c0
|
||||||
|
0x00000000c010b000 bss = .
|
||||||
|
0x00000000c010b000 _bss = .
|
||||||
|
0x00000000c010b000 __bss = .
|
||||||
|
*(.bss)
|
||||||
|
.bss 0x00000000c010b000 0x4 kernel.o
|
||||||
|
0x00000000c010b000 _timer
|
||||||
|
*fill* 0x00000000c010b004 0x4 00
|
||||||
|
.bss 0x00000000c010b008 0xf keyboard.o
|
||||||
|
0x00000000c010b014 _kbdExt
|
||||||
|
0x00000000c010b009 _kbdAscii
|
||||||
|
0x00000000c010b015 _kbdExt2
|
||||||
|
0x00000000c010b016 _ackReason
|
||||||
|
0x00000000c010b00c _kbdBufferStart
|
||||||
|
0x00000000c010b00a _kbdScan
|
||||||
|
0x00000000c010b010 _kbdBufferLen
|
||||||
|
0x00000000c010b008 _kbdFlags
|
||||||
|
*fill* 0x00000000c010b017 0x1 00
|
||||||
|
.bss 0x00000000c010b018 0x4 kio.o
|
||||||
|
0x00000000c010b018 _cursorPosition
|
||||||
|
.bss 0x00000000c010b01c 0x8 mm.o
|
||||||
|
0x00000000c010b020 _mm_megabytes
|
||||||
|
0x00000000c010b01c _mm_totalmem
|
||||||
|
.bss 0x00000000c010b024 0x4 mouse.o
|
||||||
|
0x00000000c010b024 _mouse_bytesRead
|
||||||
|
.bss 0x00000000c010b028 0x4 video.o
|
||||||
|
0x00000000c010b028 _videoMode
|
||||||
|
0x00000000c010c000 . = ALIGN (0x1000)
|
||||||
|
*fill* 0x00000000c010b02c 0x80b952800000fd4 00
|
||||||
|
COMMON 0x00000000c010c000 0x100 keyboard.o
|
||||||
|
0x0 (size before relaxing)
|
||||||
|
0x00000000c010c000 _kbdBuffer
|
||||||
|
COMMON 0x00000000c010c100 0xfa0 kio.o
|
||||||
|
0x0 (size before relaxing)
|
||||||
|
0x00000000c010c100 _console_memory
|
||||||
|
COMMON 0x00000000c010d0a0 0x20000 mm.o
|
||||||
|
0x0 (size before relaxing)
|
||||||
|
0x00000000c010d0a0 _page_bitmap
|
||||||
|
COMMON 0x00000000c012d0a0 0x18 mouse.o
|
||||||
|
0x0 (size before relaxing)
|
||||||
|
0x00000000c012d0a0 _mouse_y
|
||||||
|
0x00000000c012d0a4 _mouse_x
|
||||||
|
0x00000000c012d0a8 _mouse_inbuffer
|
||||||
|
*fill* 0x00000000c012d0b8 0x80b952800000008 00
|
||||||
|
COMMON 0x00000000c012d0c0 0x100 video.o
|
||||||
|
0x0 (size before relaxing)
|
||||||
|
0x00000000c012d0c0 _video_mode
|
||||||
|
0x00000000c012d1c0 end = .
|
||||||
|
0x00000000c012d1c0 _end = .
|
||||||
|
0x00000000c012d1c0 __end = .
|
||||||
|
LOAD ks.o
|
||||||
|
LOAD kernel.o
|
||||||
|
LOAD asmfuncs.o
|
||||||
|
LOAD fdc.o
|
||||||
|
LOAD functions.o
|
||||||
|
LOAD keyboard.o
|
||||||
|
LOAD kio.o
|
||||||
|
LOAD mm.o
|
||||||
|
LOAD mouse.o
|
||||||
|
LOAD stdfont.o
|
||||||
|
LOAD video.o
|
||||||
|
LOAD vmm.o
|
||||||
|
LOAD rtc.o
|
||||||
|
LOAD pic.o
|
||||||
|
LOAD io.o
|
||||||
|
LOAD string.o
|
||||||
|
LOAD cmos.o
|
||||||
|
OUTPUT(kernel.bin binary)
|
||||||
|
|
||||||
|
.rodata 0x00000000c012d1c0 0x1620
|
||||||
|
.rodata 0x00000000c012d1c0 0x101 kernel.o
|
||||||
|
*fill* 0x00000000c012d2c1 0xa0000001f 00
|
||||||
|
.rodata 0x00000000c012d2e0 0x113 keyboard.o
|
||||||
|
0x00000000c012d2e0 _SCAN2ASCII
|
||||||
|
0x00000000c012d360 _SCAN2ASCIISHIFT
|
||||||
|
*fill* 0x00000000c012d3f3 0xa00000001 00
|
||||||
|
.rodata 0x00000000c012d3f4 0x1e4 kio.o
|
||||||
|
*fill* 0x00000000c012d5d8 0xa00000008 00
|
||||||
|
.rodata 0x00000000c012d5e0 0x1200 stdfont.o
|
||||||
|
0x00000000c012d5e0 _stdfont8x5
|
||||||
|
0x00000000c012dde0 _stdfont10x7
|
||||||
|
|
||||||
|
.note.GNU-stack
|
||||||
|
0x0000000000000000 0x0
|
||||||
|
|
||||||
|
.comment 0x0000000000000000 0x2fd
|
||||||
|
.comment 0x0000000000000000 0x33 kernel.o
|
||||||
|
.comment 0x0000000000000033 0x33 fdc.o
|
||||||
|
.comment 0x0000000000000066 0x33 functions.o
|
||||||
|
.comment 0x0000000000000099 0x33 keyboard.o
|
||||||
|
.comment 0x00000000000000cc 0x33 kio.o
|
||||||
|
.comment 0x00000000000000ff 0x33 mm.o
|
||||||
|
.comment 0x0000000000000132 0x33 mouse.o
|
||||||
|
.comment 0x0000000000000165 0x33 stdfont.o
|
||||||
|
.comment 0x0000000000000198 0x33 video.o
|
||||||
|
.comment 0x00000000000001cb 0x33 vmm.o
|
||||||
|
.comment 0x00000000000001fe 0x33 rtc.o
|
||||||
|
.comment 0x0000000000000231 0x33 pic.o
|
||||||
|
.comment 0x0000000000000264 0x33 io.o
|
||||||
|
.comment 0x0000000000000297 0x33 string.o
|
||||||
|
.comment 0x00000000000002ca 0x33 cmos.o
|
510
kernel/lst/asmfuncs.lst
Normal file
510
kernel/lst/asmfuncs.lst
Normal file
@ -0,0 +1,510 @@
|
|||||||
|
1 ; asmfuncs.asm
|
||||||
|
2 ; Josh Holtrop
|
||||||
|
3 ; Created: 10/23/03
|
||||||
|
4 ; Modified: 02/26/04
|
||||||
|
5
|
||||||
|
6 [extern _putc]
|
||||||
|
7 [extern _console_memory]
|
||||||
|
8 [extern _cursorPosition]
|
||||||
|
9 [extern _video_drawConsole]
|
||||||
|
10 [extern _videoMode]
|
||||||
|
11
|
||||||
|
12 %macro jzfar 1
|
||||||
|
13 jnz %%skip
|
||||||
|
14 jmp %1
|
||||||
|
15 %%skip:
|
||||||
|
16
|
||||||
|
17 %endmacro
|
||||||
|
18
|
||||||
|
19 ;stores the parameter to the CR0 register
|
||||||
|
20 ;extern dword write_cr0(dword cr0);
|
||||||
|
21 [global _write_cr0]
|
||||||
|
22 _write_cr0:
|
||||||
|
23 00000000 55 push ebp
|
||||||
|
24 00000001 89E5 mov ebp, esp
|
||||||
|
25 00000003 8B4508 mov eax, [ebp+8]
|
||||||
|
26 00000006 0F22C0 mov cr0, eax
|
||||||
|
27 00000009 5D pop ebp
|
||||||
|
28 0000000A C3 ret
|
||||||
|
29
|
||||||
|
30 ;returns the value in the CR0 register
|
||||||
|
31 ;extern dword read_cr0();
|
||||||
|
32 [global _read_cr0]
|
||||||
|
33 _read_cr0:
|
||||||
|
34 0000000B 0F20C0 mov eax, cr0;
|
||||||
|
35 0000000E C3 ret
|
||||||
|
36
|
||||||
|
37 ;stores the parameter to the CR3 register
|
||||||
|
38 ;extern dword write_cr3(dword cr3);
|
||||||
|
39 [global _write_cr3]
|
||||||
|
40 _write_cr3:
|
||||||
|
41 0000000F 55 push ebp
|
||||||
|
42 00000010 89E5 mov ebp, esp
|
||||||
|
43 00000012 8B4508 mov eax, [ebp+8]
|
||||||
|
44 00000015 0F22D8 mov cr3, eax
|
||||||
|
45 00000018 5D pop ebp
|
||||||
|
46 00000019 C3 ret
|
||||||
|
47
|
||||||
|
48
|
||||||
|
49 ;returns the value in the CR2 register
|
||||||
|
50 ;extern dword read_cr2();
|
||||||
|
51 [global _read_cr2]
|
||||||
|
52 _read_cr2:
|
||||||
|
53 0000001A 0F20D0 mov eax, cr2;
|
||||||
|
54 0000001D C3 ret
|
||||||
|
55
|
||||||
|
56
|
||||||
|
57
|
||||||
|
58 ;returns the value in the CR3 register
|
||||||
|
59 ;extern dword read_cr3();
|
||||||
|
60 [global _read_cr3]
|
||||||
|
61 _read_cr3:
|
||||||
|
62 0000001E 0F20D8 mov eax, cr3;
|
||||||
|
63 00000021 C3 ret
|
||||||
|
64
|
||||||
|
65
|
||||||
|
66 ;compares one string to another
|
||||||
|
67 ;returns 0 if the strings are different
|
||||||
|
68 ;extern dword strcmp(char *str1, char *str2);
|
||||||
|
69 [global _strcmp]
|
||||||
|
70 _strcmp:
|
||||||
|
71 00000022 55 push ebp
|
||||||
|
72 00000023 89E5 mov ebp, esp
|
||||||
|
73 00000025 56 push esi
|
||||||
|
74 00000026 57 push edi
|
||||||
|
75
|
||||||
|
76 00000027 8B7508 mov esi, [ebp+8]
|
||||||
|
77 0000002A 8B7D0C mov edi, [ebp+12]
|
||||||
|
78 strcmp_loop1:
|
||||||
|
79 0000002D AC lodsb
|
||||||
|
80 0000002E 8A27 mov ah, [edi]
|
||||||
|
81 00000030 47 inc edi
|
||||||
|
82 00000031 38C4 cmp ah, al
|
||||||
|
83 00000033 750D jnz strcmp_ne
|
||||||
|
84 00000035 08C0 or al, al
|
||||||
|
85 00000037 7402 jz strcmp_e
|
||||||
|
86 00000039 EBF2 jmp strcmp_loop1
|
||||||
|
87 strcmp_e:
|
||||||
|
88 0000003B B801000000 mov eax, 1
|
||||||
|
89 00000040 EB02 jmp short strcmp_done
|
||||||
|
90 strcmp_ne:
|
||||||
|
91 00000042 31C0 xor eax, eax
|
||||||
|
92 strcmp_done:
|
||||||
|
93
|
||||||
|
94 00000044 5F pop edi
|
||||||
|
95 00000045 5E pop esi
|
||||||
|
96 00000046 5D pop ebp
|
||||||
|
97 00000047 C3 ret
|
||||||
|
98
|
||||||
|
99 ;copies a string from the source to the destination parameter
|
||||||
|
100 ;extern void strcpy(char *dest, char *src);
|
||||||
|
101 [global _strcpy]
|
||||||
|
102 _strcpy:
|
||||||
|
103 00000048 55 push ebp
|
||||||
|
104 00000049 89E5 mov ebp, esp
|
||||||
|
105 0000004B 56 push esi
|
||||||
|
106 0000004C 57 push edi
|
||||||
|
107 0000004D 8B7D08 mov edi, [ebp+8]
|
||||||
|
108 00000050 8B750C mov esi, [ebp+12]
|
||||||
|
109 strcpyloop:
|
||||||
|
110 00000053 AC lodsb
|
||||||
|
111 00000054 AA stosb
|
||||||
|
112 00000055 08C0 or al, al
|
||||||
|
113 00000057 75FA jnz strcpyloop
|
||||||
|
114 00000059 5F pop edi
|
||||||
|
115 0000005A 5E pop esi
|
||||||
|
116 0000005B 5D pop ebp
|
||||||
|
117 0000005C C3 ret
|
||||||
|
118
|
||||||
|
119 ;copies memory of n bytes from src to destination
|
||||||
|
120 ;void memcpy(void *dest, void *src, dword n);
|
||||||
|
121 [global _memcpy]
|
||||||
|
122 _memcpy:
|
||||||
|
123 0000005D 55 push ebp
|
||||||
|
124 0000005E 89E5 mov ebp, esp
|
||||||
|
125 00000060 56 push esi
|
||||||
|
126 00000061 57 push edi
|
||||||
|
127 00000062 51 push ecx
|
||||||
|
128 00000063 8B7D08 mov edi, [ebp+8]
|
||||||
|
129 00000066 8B750C mov esi, [ebp+12]
|
||||||
|
130 00000069 8B4D10 mov ecx, [ebp+16]
|
||||||
|
131
|
||||||
|
132 0000006C FC cld
|
||||||
|
133 0000006D F3A4 rep movsb
|
||||||
|
134
|
||||||
|
135 0000006F 59 pop ecx
|
||||||
|
136 00000070 5F pop edi
|
||||||
|
137 00000071 5E pop esi
|
||||||
|
138 00000072 5D pop ebp
|
||||||
|
139 00000073 C3 ret
|
||||||
|
140
|
||||||
|
141
|
||||||
|
142 ;copies memory of n dwords (n*4 bytes) from src to destination
|
||||||
|
143 ;void memcpyd(void *dest, void *src, dword n);
|
||||||
|
144 [global _memcpyd]
|
||||||
|
145 _memcpyd:
|
||||||
|
146 00000074 55 push ebp
|
||||||
|
147 00000075 89E5 mov ebp, esp
|
||||||
|
148 00000077 56 push esi
|
||||||
|
149 00000078 57 push edi
|
||||||
|
150 00000079 51 push ecx
|
||||||
|
151 0000007A 8B7D08 mov edi, [ebp+8]
|
||||||
|
152 0000007D 8B750C mov esi, [ebp+12]
|
||||||
|
153 00000080 8B4D10 mov ecx, [ebp+16]
|
||||||
|
154
|
||||||
|
155 00000083 FC cld
|
||||||
|
156 00000084 F3A5 rep movsd
|
||||||
|
157
|
||||||
|
158 00000086 59 pop ecx
|
||||||
|
159 00000087 5F pop edi
|
||||||
|
160 00000088 5E pop esi
|
||||||
|
161 00000089 5D pop ebp
|
||||||
|
162 0000008A C3 ret
|
||||||
|
163
|
||||||
|
164
|
||||||
|
165 ;sets num bytes at buffer to the value of c
|
||||||
|
166 ;void *memset(void *buffer, int c, int num);
|
||||||
|
167 [global _memset]
|
||||||
|
168 _memset:
|
||||||
|
169 0000008B 55 push ebp
|
||||||
|
170 0000008C 89E5 mov ebp, esp
|
||||||
|
171 0000008E 57 push edi
|
||||||
|
172 0000008F 51 push ecx
|
||||||
|
173 00000090 8B7D08 mov edi, [ebp+8]
|
||||||
|
174 00000093 57 push edi ;save for return address
|
||||||
|
175 00000094 8B450C mov eax, [ebp+12]
|
||||||
|
176 00000097 8B4D10 mov ecx, [ebp+16]
|
||||||
|
177
|
||||||
|
178 0000009A F3AA rep stosb
|
||||||
|
179
|
||||||
|
180 0000009C 58 pop eax
|
||||||
|
181 0000009D 59 pop ecx
|
||||||
|
182 0000009E 5F pop edi
|
||||||
|
183 0000009F 5D pop ebp
|
||||||
|
184 000000A0 C3 ret
|
||||||
|
185
|
||||||
|
186
|
||||||
|
187 ;sets num words at buffer to the value of c
|
||||||
|
188 ;void *memsetw(void *buffer, int c, int num);
|
||||||
|
189 [global _memsetw]
|
||||||
|
190 _memsetw:
|
||||||
|
191 000000A1 55 push ebp
|
||||||
|
192 000000A2 89E5 mov ebp, esp
|
||||||
|
193 000000A4 57 push edi
|
||||||
|
194 000000A5 51 push ecx
|
||||||
|
195 000000A6 8B7D08 mov edi, [ebp+8]
|
||||||
|
196 000000A9 57 push edi ;save for return address
|
||||||
|
197 000000AA 8B450C mov eax, [ebp+12]
|
||||||
|
198 000000AD 8B4D10 mov ecx, [ebp+16]
|
||||||
|
199
|
||||||
|
200 000000B0 F366AB rep stosw
|
||||||
|
201
|
||||||
|
202 000000B3 58 pop eax
|
||||||
|
203 000000B4 59 pop ecx
|
||||||
|
204 000000B5 5F pop edi
|
||||||
|
205 000000B6 5D pop ebp
|
||||||
|
206 000000B7 C3 ret
|
||||||
|
207
|
||||||
|
208
|
||||||
|
209 ;sets num dwords at buffer to the value of c
|
||||||
|
210 ;void *memsetd(void *buffer, int c, int num);
|
||||||
|
211 [global _memsetd]
|
||||||
|
212 _memsetd:
|
||||||
|
213 000000B8 55 push ebp
|
||||||
|
214 000000B9 89E5 mov ebp, esp
|
||||||
|
215 000000BB 57 push edi
|
||||||
|
216 000000BC 51 push ecx
|
||||||
|
217 000000BD 8B7D08 mov edi, [ebp+8]
|
||||||
|
218 000000C0 57 push edi ;save for return address
|
||||||
|
219 000000C1 8B450C mov eax, [ebp+12]
|
||||||
|
220 000000C4 8B4D10 mov ecx, [ebp+16]
|
||||||
|
221
|
||||||
|
222 000000C7 F3AB rep stosd
|
||||||
|
223
|
||||||
|
224 000000C9 58 pop eax
|
||||||
|
225 000000CA 59 pop ecx
|
||||||
|
226 000000CB 5F pop edi
|
||||||
|
227 000000CC 5D pop ebp
|
||||||
|
228 000000CD C3 ret
|
||||||
|
229
|
||||||
|
230
|
||||||
|
231 ;returns the number of characters in a string
|
||||||
|
232 ;extern dword strlen(char *str);
|
||||||
|
233 [global _strlen]
|
||||||
|
234 _strlen:
|
||||||
|
235 000000CE 55 push ebp
|
||||||
|
236 000000CF 89E5 mov ebp, esp
|
||||||
|
237 000000D1 56 push esi
|
||||||
|
238 000000D2 53 push ebx
|
||||||
|
239 000000D3 8B7508 mov esi, [ebp+8]
|
||||||
|
240 000000D6 31DB xor ebx, ebx
|
||||||
|
241 strlenloop:
|
||||||
|
242 000000D8 AC lodsb
|
||||||
|
243 000000D9 08C0 or al, al
|
||||||
|
244 000000DB 7403 jz strlendone
|
||||||
|
245 000000DD 43 inc ebx
|
||||||
|
246 000000DE EBF8 jmp strlenloop
|
||||||
|
247 strlendone:
|
||||||
|
248 000000E0 89D8 mov eax, ebx
|
||||||
|
249 000000E2 5B pop ebx
|
||||||
|
250 000000E3 5E pop esi
|
||||||
|
251 000000E4 5D pop ebp
|
||||||
|
252 000000E5 C3 ret
|
||||||
|
253
|
||||||
|
254 ;this function invalidates the page directory/table entry that
|
||||||
|
255 ; would be used to access the memory address given in the parameter
|
||||||
|
256 ;extern void invlpg_(dword addr);
|
||||||
|
257 [global _invlpg_]
|
||||||
|
258 _invlpg_:
|
||||||
|
259 000000E6 8B442404 mov eax, [esp+4]
|
||||||
|
260 000000EA 0F0138 invlpg [eax]
|
||||||
|
261 000000ED C3 ret
|
||||||
|
262
|
||||||
|
263
|
||||||
|
264 ;
|
||||||
|
265 ;void writeCursorPosition(word pos)
|
||||||
|
266 ;
|
||||||
|
267 [global _writeCursorPosition]
|
||||||
|
268 _writeCursorPosition:
|
||||||
|
269 000000EE 55 push ebp
|
||||||
|
270 000000EF 89E5 mov ebp, esp
|
||||||
|
271
|
||||||
|
272 000000F1 50 push eax
|
||||||
|
273 000000F2 53 push ebx
|
||||||
|
274 000000F3 52 push edx
|
||||||
|
275
|
||||||
|
276 000000F4 8B4508 mov eax, [ebp+8] ;cursor position in ax
|
||||||
|
277
|
||||||
|
278 000000F7 88C3 mov bl, al
|
||||||
|
279 000000F9 66BAD403 mov dx, 0x03D4
|
||||||
|
280 000000FD B00E mov al, 0x0E
|
||||||
|
281 000000FF EE out dx, al
|
||||||
|
282
|
||||||
|
283 00000100 6642 inc dx
|
||||||
|
284 00000102 88E0 mov al, ah
|
||||||
|
285 00000104 EE out dx, al
|
||||||
|
286
|
||||||
|
287 00000105 664A dec dx
|
||||||
|
288 00000107 B00F mov al, 0x0F
|
||||||
|
289 00000109 EE out dx, al
|
||||||
|
290
|
||||||
|
291 0000010A 6642 inc dx
|
||||||
|
292 0000010C 88D8 mov al, bl
|
||||||
|
293 0000010E EE out dx, al
|
||||||
|
294
|
||||||
|
295 0000010F 5A pop edx
|
||||||
|
296 00000110 5B pop ebx
|
||||||
|
297 00000111 58 pop eax
|
||||||
|
298 00000112 5D pop ebp
|
||||||
|
299
|
||||||
|
300 00000113 C3 ret
|
||||||
|
301
|
||||||
|
302
|
||||||
|
303 ;
|
||||||
|
304 ;word getCursorPosition()
|
||||||
|
305 ;
|
||||||
|
306 [global _getCursorPosition]
|
||||||
|
307 _getCursorPosition:
|
||||||
|
308 00000114 53 push ebx
|
||||||
|
309 00000115 52 push edx
|
||||||
|
310
|
||||||
|
311 00000116 31C0 xor eax, eax
|
||||||
|
312 00000118 66BAD403 mov dx, 0x03D4
|
||||||
|
313 0000011C B00E mov al, 0x0E
|
||||||
|
314 0000011E EE out dx, al
|
||||||
|
315
|
||||||
|
316 0000011F 6642 inc dx
|
||||||
|
317 00000121 EC in al, dx
|
||||||
|
318 00000122 88C3 mov bl, al
|
||||||
|
319
|
||||||
|
320 00000124 664A dec dx
|
||||||
|
321 00000126 B00F mov al, 0x0F
|
||||||
|
322 00000128 EE out dx, al
|
||||||
|
323
|
||||||
|
324 00000129 6642 inc dx
|
||||||
|
325 0000012B EC in al, dx
|
||||||
|
326 0000012C 88DC mov ah, bl
|
||||||
|
327
|
||||||
|
328 0000012E 5A pop edx
|
||||||
|
329 0000012F 5B pop ebx
|
||||||
|
330
|
||||||
|
331 00000130 C3 ret
|
||||||
|
332
|
||||||
|
333
|
||||||
|
334 ;
|
||||||
|
335 ;int puts(char *str)
|
||||||
|
336 ;
|
||||||
|
337 [global _puts]
|
||||||
|
338 _puts:
|
||||||
|
339 00000131 55 push ebp
|
||||||
|
340 00000132 89E5 mov ebp, esp
|
||||||
|
341 00000134 56 push esi
|
||||||
|
342 00000135 50 push eax
|
||||||
|
343 00000136 8B7508 mov esi, [ebp+8] ;esi = to string
|
||||||
|
344 puts_loop:
|
||||||
|
345 00000139 AC lodsb
|
||||||
|
346 0000013A 3C00 cmp al, 0
|
||||||
|
347 0000013C 740E jz puts_done
|
||||||
|
348 0000013E 50 push eax
|
||||||
|
349 0000013F E8(00000000) call _putc
|
||||||
|
350 00000144 81C404000000 add esp, 4
|
||||||
|
351 0000014A EBED jmp puts_loop
|
||||||
|
352
|
||||||
|
353 puts_done:
|
||||||
|
354 0000014C 58 pop eax
|
||||||
|
355 0000014D 5E pop esi
|
||||||
|
356 0000014E 5D pop ebp
|
||||||
|
357 0000014F C3 ret
|
||||||
|
358
|
||||||
|
359
|
||||||
|
360
|
||||||
|
361
|
||||||
|
362 [global _putDecu]
|
||||||
|
363 _putDecu:
|
||||||
|
364 00000150 55 push ebp
|
||||||
|
365 00000151 89E5 mov ebp, esp
|
||||||
|
366 00000153 81EC18000000 sub esp, 24
|
||||||
|
367 00000159 C745FC01000000 mov DWORD [ebp-4], 1
|
||||||
|
368 00000160 C645FB00 mov BYTE [ebp-5], 0
|
||||||
|
369 L2:
|
||||||
|
370 00000164 8B5508 mov edx, DWORD [ebp+8]
|
||||||
|
371 00000167 B8CDCCCCCC mov eax, -858993459
|
||||||
|
372 0000016C F7E2 mul edx
|
||||||
|
373 0000016E 89D0 mov eax, edx
|
||||||
|
374 00000170 C1E803 shr eax, 3
|
||||||
|
375 00000173 3B45FC cmp eax, DWORD [ebp-4]
|
||||||
|
376 00000176 7305 jae L4
|
||||||
|
377 00000178 E912000000 jmp L3
|
||||||
|
378 L4:
|
||||||
|
379 0000017D 8B45FC mov eax, DWORD [ebp-4]
|
||||||
|
380 00000180 89C2 mov edx, eax
|
||||||
|
381 00000182 C1E202 sal edx, 2
|
||||||
|
382 00000185 01C2 add edx, eax
|
||||||
|
383 00000187 8D0412 lea eax, [edx+edx]
|
||||||
|
384 0000018A 8945FC mov DWORD [ebp-4], eax
|
||||||
|
385 0000018D EBD5 jmp L2
|
||||||
|
386 L3:
|
||||||
|
387 0000018F 90 nop
|
||||||
|
388 L5:
|
||||||
|
389 00000190 817DFC01000000 cmp DWORD [ebp-4], 1
|
||||||
|
390 00000197 7705 ja L7
|
||||||
|
391 00000199 E959000000 jmp L6
|
||||||
|
392 L7:
|
||||||
|
393 0000019E 8B5508 mov edx, DWORD [ebp+8]
|
||||||
|
394 000001A1 89D0 mov eax, edx
|
||||||
|
395 000001A3 BA00000000 mov edx, 0
|
||||||
|
396 000001A8 F775FC div DWORD [ebp-4]
|
||||||
|
397 000001AB 8945F4 mov DWORD [ebp-12], eax
|
||||||
|
398 000001AE 8A45F4 mov al, BYTE [ebp-12]
|
||||||
|
399 000001B1 8845FB mov BYTE [ebp-5], al
|
||||||
|
400 000001B4 B800000000 mov eax, 0
|
||||||
|
401 000001B9 8A45FB mov al, BYTE [ebp-5]
|
||||||
|
402 000001BC 0FAF45FC imul eax, DWORD [ebp-4]
|
||||||
|
403 000001C0 294508 sub DWORD [ebp+8], eax
|
||||||
|
404 000001C3 8B55FC mov edx, DWORD [ebp-4]
|
||||||
|
405 000001C6 B8CDCCCCCC mov eax, -858993459
|
||||||
|
406 000001CB F7E2 mul edx
|
||||||
|
407 000001CD 89D0 mov eax, edx
|
||||||
|
408 000001CF C1E803 shr eax, 3
|
||||||
|
409 000001D2 8945FC mov DWORD [ebp-4], eax
|
||||||
|
410 000001D5 8D45FB lea eax, [ebp-5]
|
||||||
|
411 000001D8 800030 add BYTE [eax], 48
|
||||||
|
412 000001DB 81EC0C000000 sub esp, 12
|
||||||
|
413 000001E1 B800000000 mov eax, 0
|
||||||
|
414 000001E6 8A45FB mov al, BYTE [ebp-5]
|
||||||
|
415 000001E9 50 push eax
|
||||||
|
416 000001EA E8(00000000) call _putc
|
||||||
|
417 000001EF 81C410000000 add esp, 16
|
||||||
|
418 000001F5 EB99 jmp L5
|
||||||
|
419 L6:
|
||||||
|
420 000001F7 81EC0C000000 sub esp, 12
|
||||||
|
421 000001FD 8A4508 mov al, BYTE [ebp+8]
|
||||||
|
422 00000200 0530000000 add eax, 48
|
||||||
|
423 00000205 25FF000000 and eax, 255
|
||||||
|
424 0000020A 50 push eax
|
||||||
|
425 0000020B E8(00000000) call _putc
|
||||||
|
426 00000210 81C410000000 add esp, 16
|
||||||
|
427 00000216 C9 leave
|
||||||
|
428 00000217 C3 ret
|
||||||
|
429
|
||||||
|
430
|
||||||
|
431
|
||||||
|
432
|
||||||
|
433 [global _putDec]
|
||||||
|
434 _putDec:
|
||||||
|
435 00000218 55 push ebp
|
||||||
|
436 00000219 89E5 mov ebp, esp
|
||||||
|
437 0000021B 81EC18000000 sub esp, 24
|
||||||
|
438 00000221 817D0800000000 cmp DWORD [ebp+8], 0
|
||||||
|
439 00000228 7919 jns L9
|
||||||
|
440 0000022A 81EC0C000000 sub esp, 12
|
||||||
|
441 00000230 682D000000 push 45
|
||||||
|
442 00000235 E8(00000000) call _putc
|
||||||
|
443 0000023A 81C410000000 add esp, 16
|
||||||
|
444 00000240 F75D08 neg DWORD [ebp+8]
|
||||||
|
445 L9:
|
||||||
|
446 00000243 C745FC01000000 mov DWORD [ebp-4], 1
|
||||||
|
447 0000024A C645FB00 mov BYTE [ebp-5], 0
|
||||||
|
448 L10:
|
||||||
|
449 0000024E 8B4508 mov eax, DWORD [ebp+8]
|
||||||
|
450 00000251 3B45FC cmp eax, DWORD [ebp-4]
|
||||||
|
451 00000254 7305 jae L12
|
||||||
|
452 00000256 E912000000 jmp L11
|
||||||
|
453 L12:
|
||||||
|
454 0000025B 8B45FC mov eax, DWORD [ebp-4]
|
||||||
|
455 0000025E 89C2 mov edx, eax
|
||||||
|
456 00000260 C1E202 sal edx, 2
|
||||||
|
457 00000263 01C2 add edx, eax
|
||||||
|
458 00000265 8D0412 lea eax, [edx+edx]
|
||||||
|
459 00000268 8945FC mov DWORD [ebp-4], eax
|
||||||
|
460 0000026B EBE1 jmp L10
|
||||||
|
461 L11:
|
||||||
|
462 0000026D 8B55FC mov edx, DWORD [ebp-4]
|
||||||
|
463 00000270 B8CDCCCCCC mov eax, -858993459
|
||||||
|
464 00000275 F7E2 mul edx
|
||||||
|
465 00000277 89D0 mov eax, edx
|
||||||
|
466 00000279 C1E803 shr eax, 3
|
||||||
|
467 0000027C 8945FC mov DWORD [ebp-4], eax
|
||||||
|
468 L13:
|
||||||
|
469 0000027F 817DFC01000000 cmp DWORD [ebp-4], 1
|
||||||
|
470 00000286 7705 ja L15
|
||||||
|
471 00000288 E959000000 jmp L14
|
||||||
|
472 L15:
|
||||||
|
473 0000028D 8B5508 mov edx, DWORD [ebp+8]
|
||||||
|
474 00000290 89D0 mov eax, edx
|
||||||
|
475 00000292 BA00000000 mov edx, 0
|
||||||
|
476 00000297 F775FC div DWORD [ebp-4]
|
||||||
|
477 0000029A 8945F4 mov DWORD [ebp-12], eax
|
||||||
|
478 0000029D 8A45F4 mov al, BYTE [ebp-12]
|
||||||
|
479 000002A0 8845FB mov BYTE [ebp-5], al
|
||||||
|
480 000002A3 B800000000 mov eax, 0
|
||||||
|
481 000002A8 8A45FB mov al, BYTE [ebp-5]
|
||||||
|
482 000002AB 0FAF45FC imul eax, DWORD [ebp-4]
|
||||||
|
483 000002AF 294508 sub DWORD [ebp+8], eax
|
||||||
|
484 000002B2 8B55FC mov edx, DWORD [ebp-4]
|
||||||
|
485 000002B5 B8CDCCCCCC mov eax, -858993459
|
||||||
|
486 000002BA F7E2 mul edx
|
||||||
|
487 000002BC 89D0 mov eax, edx
|
||||||
|
488 000002BE C1E803 shr eax, 3
|
||||||
|
489 000002C1 8945FC mov DWORD [ebp-4], eax
|
||||||
|
490 000002C4 8D45FB lea eax, [ebp-5]
|
||||||
|
491 000002C7 800030 add BYTE [eax], 48
|
||||||
|
492 000002CA 81EC0C000000 sub esp, 12
|
||||||
|
493 000002D0 B800000000 mov eax, 0
|
||||||
|
494 000002D5 8A45FB mov al, BYTE [ebp-5]
|
||||||
|
495 000002D8 50 push eax
|
||||||
|
496 000002D9 E8(00000000) call _putc
|
||||||
|
497 000002DE 81C410000000 add esp, 16
|
||||||
|
498 000002E4 EB99 jmp L13
|
||||||
|
499 L14:
|
||||||
|
500 000002E6 81EC0C000000 sub esp, 12
|
||||||
|
501 000002EC 8A4508 mov al, BYTE [ebp+8]
|
||||||
|
502 000002EF 0530000000 add eax, 48
|
||||||
|
503 000002F4 25FF000000 and eax, 255
|
||||||
|
504 000002F9 50 push eax
|
||||||
|
505 000002FA E8(00000000) call _putc
|
||||||
|
506 000002FF 81C410000000 add esp, 16
|
||||||
|
507 00000305 C9 leave
|
||||||
|
508 00000306 C3 ret
|
||||||
|
509
|
||||||
|
510
|
492
kernel/lst/kernel.lst
Normal file
492
kernel/lst/kernel.lst
Normal file
@ -0,0 +1,492 @@
|
|||||||
|
1 ;kernel.asm
|
||||||
|
2 ;Author: Josh Holtrop
|
||||||
|
3 ;Date: 10/30/03
|
||||||
|
4 ;Modified: 10/30/03
|
||||||
|
5
|
||||||
|
6 %define GDT_P 0x100000; ;1mb physical - Global Descriptor Table space
|
||||||
|
7 %define GDT_V GDT_P+0xC0000000
|
||||||
|
8 %define IDT_P 0x102000 ;1mb+8kb - Interrupt Descriptor Table space
|
||||||
|
9 %define IDT_V IDT_P+0xC0000000
|
||||||
|
10 %define PDBR_P 0x104000 ;1mb+16kb - Page Directory Base Register (first PD)
|
||||||
|
11 %define PDBR_V PDBR_P+0xC0000000
|
||||||
|
12 %define LOPT_P 0x105000 ;1mb+20kb - LOw Page Table for mapping first 4mb
|
||||||
|
13 %define LOPT_V LOPT_P+0xC0000000
|
||||||
|
14 %define KERNEL_P 0x106000 ;1mb+24kb - the kernel's physical address
|
||||||
|
15 %define KERNEL_V KERNEL_P+0xC0000000 ;3gb+1mb+24kb, the virtual address of the kernel
|
||||||
|
16
|
||||||
|
17 [global _start]
|
||||||
|
18 [extern _isr]
|
||||||
|
19 [extern _k_init]
|
||||||
|
20 [extern _putc]
|
||||||
|
21
|
||||||
|
22 bits 32
|
||||||
|
23
|
||||||
|
24 ;This is where the kernel begins execution
|
||||||
|
25 ;At this point, the temporary gdt is set up to "map" 0xC000_0000 to 0x0.
|
||||||
|
26 ;We must enable paging with the first 4mb mapped 1:1 virtual:physical
|
||||||
|
27 ; and with the 4mb starting at 0xC000_0000 mapped to the first 4mb physical.
|
||||||
|
28 ;Then we can start using our "real" gdt, then unmap the lower 4mb.
|
||||||
|
29 _start:
|
||||||
|
30 00000000 FA cli ;if they weren't already off
|
||||||
|
31
|
||||||
|
32 00000001 31C0 xor eax, eax
|
||||||
|
33 00000003 BF004010C0 mov edi, PDBR_V
|
||||||
|
34 00000008 B900040000 mov ecx, 1024 ;clear the PDBR
|
||||||
|
35 0000000D F3AB rep stosd
|
||||||
|
36 0000000F C705004010C0035010- mov [PDBR_V], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
||||||
|
37 00000018 00
|
||||||
|
38 00000019 C705004C10C0035010- mov [PDBR_V+0xC00], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
|
||||||
|
39 00000022 00
|
||||||
|
40
|
||||||
|
41 00000023 BF005010C0 mov edi, LOPT_V
|
||||||
|
42 00000028 B900040000 mov ecx, 1024
|
||||||
|
43 0000002D B803000000 mov eax, 0x03 ;starting physical address = 0x0 (read/write, present flags)
|
||||||
|
44 fill_lopt_loop: ;fill the page table
|
||||||
|
45 00000032 AB stosd
|
||||||
|
46 00000033 0500100000 add eax, 4096 ;increment next phsyical address by 4kb
|
||||||
|
47 00000038 E2F8 loop fill_lopt_loop
|
||||||
|
48
|
||||||
|
49 0000003A B800401000 mov eax, PDBR_P
|
||||||
|
50 0000003F 0F22D8 mov cr3, eax ;store the Page Directory Base Address
|
||||||
|
51 00000042 0F20C0 mov eax, cr0
|
||||||
|
52 00000045 0D00000080 or eax, 0x80000000 ;set page enable bit
|
||||||
|
53 0000004A 0F22C0 mov cr0, eax ;now paging is active!
|
||||||
|
54
|
||||||
|
55
|
||||||
|
56 0000004D BF000010C0 mov edi, GDT_V
|
||||||
|
57 00000052 BE[D4000000] mov esi, gdt
|
||||||
|
58 00000057 B948000000 mov ecx, gdt_end-gdt
|
||||||
|
59 copy_gdt:
|
||||||
|
60 0000005C AC lodsb
|
||||||
|
61 0000005D AA stosb
|
||||||
|
62 0000005E E2FC loop copy_gdt
|
||||||
|
63
|
||||||
|
64 00000060 BF002010C0 mov edi, IDT_V ;destination
|
||||||
|
65 00000065 BE[22010000] mov esi, isr_0 ;address of isr0
|
||||||
|
66 0000006A BA0B000000 mov edx, isr_1-isr_0 ;distance between isr labels
|
||||||
|
67 0000006F B932000000 mov ecx, 50 ;number of isrlabels
|
||||||
|
68 fill_idt:
|
||||||
|
69 00000074 89F3 mov ebx, esi
|
||||||
|
70 00000076 6689F0 mov ax, si
|
||||||
|
71 00000079 66AB stosw ;0 offset 15:0
|
||||||
|
72 0000007B 66B80800 mov ax, KERNEL_CODE
|
||||||
|
73 0000007F 66AB stosw ;2 selector 15:0
|
||||||
|
74 00000081 66B8008E mov ax, 0x8E00
|
||||||
|
75 00000085 66AB stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
|
||||||
|
76 00000087 C1EE10 shr esi, 16
|
||||||
|
77 0000008A 6689F0 mov ax, si
|
||||||
|
78 0000008D 66AB stosw ;6 offset 31:16
|
||||||
|
79 0000008F 89DE mov esi, ebx
|
||||||
|
80 00000091 01D6 add esi, edx
|
||||||
|
81 00000093 E2DF loop fill_idt
|
||||||
|
82 00000095 66C705842110C000EE mov word [IDT_V+0x30*8+4], 0xEE00 ;interrupt 0x30 has user priviledges
|
||||||
|
83
|
||||||
|
84 0000009E 0F0115[CE000000] lgdt [gdtr] ;load gdt
|
||||||
|
85 000000A5 EA[AC000000]0800 jmp KERNEL_CODE:newgdtcontinue
|
||||||
|
86 newgdtcontinue:
|
||||||
|
87 000000AC 66B81000 mov ax, KERNEL_DATA
|
||||||
|
88 000000B0 8EC0 mov es, ax
|
||||||
|
89 000000B2 8ED8 mov ds, ax
|
||||||
|
90 000000B4 8EE8 mov gs, ax
|
||||||
|
91 000000B6 8EE0 mov fs, ax
|
||||||
|
92 000000B8 8ED0 mov ss, ax
|
||||||
|
93 000000BA BC000020C0 mov esp, 0xc0200000 ;stack just under 3gb+2mb, moves downward
|
||||||
|
94 000000BF 0F011D[1C010000] lidt [idtr] ;load idt
|
||||||
|
95
|
||||||
|
96 000000C6 E8(00000000) call _k_init
|
||||||
|
97 haltit:
|
||||||
|
98 000000CB F4 hlt ;halt processor when k_init is done
|
||||||
|
99 000000CC EBFD jmp haltit ;shouldn't get here...
|
||||||
|
100
|
||||||
|
101 %include "gdt.inc"
|
||||||
|
102 <1> ;gdt.inc
|
||||||
|
103 <1> ;Author: Josh Holtrop
|
||||||
|
104 <1> ;Date: 10/30/03
|
||||||
|
105 <1> ;Modified: 03/02/04
|
||||||
|
106 <1>
|
||||||
|
107 <1> gdtr:
|
||||||
|
108 000000CE 4700 <1> dw gdt_end-gdt-1
|
||||||
|
109 000000D0 000010C0 <1> dd GDT_V
|
||||||
|
110 <1> gdt:
|
||||||
|
111 000000D4 00000000 <1> dd 0
|
||||||
|
112 000000D8 00000000 <1> dd 0
|
||||||
|
113 <1> KERNEL_CODE equ $-gdt
|
||||||
|
114 000000DC FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
115 000000DE 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
116 000000E0 00 <1> db 0x00 ;base 23:16
|
||||||
|
117 000000E1 9A <1> db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
118 000000E2 CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
119 000000E3 00 <1> db 0x00 ;base 31:24
|
||||||
|
120 <1> KERNEL_DATA equ $-gdt
|
||||||
|
121 000000E4 FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
122 000000E6 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
123 000000E8 00 <1> db 0x00 ;base 23:16
|
||||||
|
124 000000E9 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
125 000000EA CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
126 000000EB 00 <1> db 0x00 ;base 31:24
|
||||||
|
127 <1> USER_CODE equ $-gdt
|
||||||
|
128 000000EC FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
129 000000EE 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
130 000000F0 00 <1> db 0x00 ;base 23:16
|
||||||
|
131 000000F1 FA <1> db 0xFA ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
132 000000F2 CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
133 000000F3 00 <1> db 0x00 ;base 31:24
|
||||||
|
134 <1> USER_DATA equ $-gdt
|
||||||
|
135 000000F4 FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
136 000000F6 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
137 000000F8 00 <1> db 0x00 ;base 23:16
|
||||||
|
138 000000F9 F2 <1> db 0xF2 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
139 000000FA CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
140 000000FB 00 <1> db 0x00 ;base 31:24
|
||||||
|
141 <1> gVESA_CODE equ $-gdt
|
||||||
|
142 000000FC FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
143 000000FE 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
144 00000100 00 <1> db 0x00 ;base 23:16
|
||||||
|
145 00000101 9A <1> db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
146 00000102 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
147 00000103 00 <1> db 0x00 ;base 31:24
|
||||||
|
148 <1> VESA_DATA equ $-gdt
|
||||||
|
149 00000104 FFFF <1> dw 0xffff ;limit 15:0
|
||||||
|
150 00000106 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
151 00000108 00 <1> db 0x00 ;base 23:16
|
||||||
|
152 00000109 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
153 0000010A 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
154 0000010B 00 <1> db 0x00 ;base 31:24
|
||||||
|
155 <1> VIDEO_TEXT equ $-gdt
|
||||||
|
156 0000010C FF7F <1> dw 0x7FFF ;limit 15:0
|
||||||
|
157 0000010E 0080 <1> dw 0x8000 ;base 15:0
|
||||||
|
158 00000110 0B <1> db 0x0B ;base 23:16
|
||||||
|
159 00000111 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
160 00000112 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
161 00000113 00 <1> db 0x00 ;base 31:24
|
||||||
|
162 <1> VIDEO_GRAPHICS equ $-gdt
|
||||||
|
163 00000114 FFFF <1> dw 0xFFFF ;limit 15:0
|
||||||
|
164 00000116 0000 <1> dw 0x0000 ;base 15:0
|
||||||
|
165 00000118 0A <1> db 0x0A ;base 23:16
|
||||||
|
166 00000119 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
|
167 0000011A 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
|
168 0000011B 00 <1> db 0x00 ;base 31:24
|
||||||
|
169 <1> gdt_end:
|
||||||
|
170 <1>
|
||||||
|
171 <1>
|
||||||
|
172 <1>
|
||||||
|
173 %include "idt.inc"
|
||||||
|
174 <1> ;idt.inc
|
||||||
|
175 <1> ;Author: Josh Holtrop
|
||||||
|
176 <1> ;Date: 10/30/03
|
||||||
|
177 <1> ;Modified: 03/02/04
|
||||||
|
178 <1>
|
||||||
|
179 <1> idtr:
|
||||||
|
180 0000011C 8F01 <1> dw 50*8-1 ;size of idt
|
||||||
|
181 0000011E 002010C0 <1> dd IDT_V ;address of idt
|
||||||
|
182 <1>
|
||||||
|
183 <1>
|
||||||
|
184 <1> %macro isr_label 1
|
||||||
|
185 <1> isr_%1:
|
||||||
|
186 <1> push eax
|
||||||
|
187 <1> mov eax, %1
|
||||||
|
188 <1> jmp isr_main
|
||||||
|
189 <1> %endmacro
|
||||||
|
190 <1>
|
||||||
|
191 <1> isr_label 0
|
||||||
|
192 <2> isr_%1:
|
||||||
|
193 00000122 50 <2> push eax
|
||||||
|
194 00000123 B800000000 <2> mov eax, %1
|
||||||
|
195 00000128 E91B020000 <2> jmp isr_main
|
||||||
|
196 <1> isr_label 1
|
||||||
|
197 <2> isr_%1:
|
||||||
|
198 0000012D 50 <2> push eax
|
||||||
|
199 0000012E B801000000 <2> mov eax, %1
|
||||||
|
200 00000133 E910020000 <2> jmp isr_main
|
||||||
|
201 <1> isr_label 2
|
||||||
|
202 <2> isr_%1:
|
||||||
|
203 00000138 50 <2> push eax
|
||||||
|
204 00000139 B802000000 <2> mov eax, %1
|
||||||
|
205 0000013E E905020000 <2> jmp isr_main
|
||||||
|
206 <1> isr_label 3
|
||||||
|
207 <2> isr_%1:
|
||||||
|
208 00000143 50 <2> push eax
|
||||||
|
209 00000144 B803000000 <2> mov eax, %1
|
||||||
|
210 00000149 E9FA010000 <2> jmp isr_main
|
||||||
|
211 <1> isr_label 4
|
||||||
|
212 <2> isr_%1:
|
||||||
|
213 0000014E 50 <2> push eax
|
||||||
|
214 0000014F B804000000 <2> mov eax, %1
|
||||||
|
215 00000154 E9EF010000 <2> jmp isr_main
|
||||||
|
216 <1> isr_label 5
|
||||||
|
217 <2> isr_%1:
|
||||||
|
218 00000159 50 <2> push eax
|
||||||
|
219 0000015A B805000000 <2> mov eax, %1
|
||||||
|
220 0000015F E9E4010000 <2> jmp isr_main
|
||||||
|
221 <1> isr_label 6
|
||||||
|
222 <2> isr_%1:
|
||||||
|
223 00000164 50 <2> push eax
|
||||||
|
224 00000165 B806000000 <2> mov eax, %1
|
||||||
|
225 0000016A E9D9010000 <2> jmp isr_main
|
||||||
|
226 <1> isr_label 7
|
||||||
|
227 <2> isr_%1:
|
||||||
|
228 0000016F 50 <2> push eax
|
||||||
|
229 00000170 B807000000 <2> mov eax, %1
|
||||||
|
230 00000175 E9CE010000 <2> jmp isr_main
|
||||||
|
231 <1> isr_label 8
|
||||||
|
232 <2> isr_%1:
|
||||||
|
233 0000017A 50 <2> push eax
|
||||||
|
234 0000017B B808000000 <2> mov eax, %1
|
||||||
|
235 00000180 E9C3010000 <2> jmp isr_main
|
||||||
|
236 <1> isr_label 9
|
||||||
|
237 <2> isr_%1:
|
||||||
|
238 00000185 50 <2> push eax
|
||||||
|
239 00000186 B809000000 <2> mov eax, %1
|
||||||
|
240 0000018B E9B8010000 <2> jmp isr_main
|
||||||
|
241 <1> isr_label 10
|
||||||
|
242 <2> isr_%1:
|
||||||
|
243 00000190 50 <2> push eax
|
||||||
|
244 00000191 B80A000000 <2> mov eax, %1
|
||||||
|
245 00000196 E9AD010000 <2> jmp isr_main
|
||||||
|
246 <1> isr_label 11
|
||||||
|
247 <2> isr_%1:
|
||||||
|
248 0000019B 50 <2> push eax
|
||||||
|
249 0000019C B80B000000 <2> mov eax, %1
|
||||||
|
250 000001A1 E9A2010000 <2> jmp isr_main
|
||||||
|
251 <1> isr_label 12
|
||||||
|
252 <2> isr_%1:
|
||||||
|
253 000001A6 50 <2> push eax
|
||||||
|
254 000001A7 B80C000000 <2> mov eax, %1
|
||||||
|
255 000001AC E997010000 <2> jmp isr_main
|
||||||
|
256 <1> isr_label 13
|
||||||
|
257 <2> isr_%1:
|
||||||
|
258 000001B1 50 <2> push eax
|
||||||
|
259 000001B2 B80D000000 <2> mov eax, %1
|
||||||
|
260 000001B7 E98C010000 <2> jmp isr_main
|
||||||
|
261 <1> isr_label 14
|
||||||
|
262 <2> isr_%1:
|
||||||
|
263 000001BC 50 <2> push eax
|
||||||
|
264 000001BD B80E000000 <2> mov eax, %1
|
||||||
|
265 000001C2 E981010000 <2> jmp isr_main
|
||||||
|
266 <1> isr_label 15
|
||||||
|
267 <2> isr_%1:
|
||||||
|
268 000001C7 50 <2> push eax
|
||||||
|
269 000001C8 B80F000000 <2> mov eax, %1
|
||||||
|
270 000001CD E976010000 <2> jmp isr_main
|
||||||
|
271 <1> isr_label 16
|
||||||
|
272 <2> isr_%1:
|
||||||
|
273 000001D2 50 <2> push eax
|
||||||
|
274 000001D3 B810000000 <2> mov eax, %1
|
||||||
|
275 000001D8 E96B010000 <2> jmp isr_main
|
||||||
|
276 <1> isr_label 17
|
||||||
|
277 <2> isr_%1:
|
||||||
|
278 000001DD 50 <2> push eax
|
||||||
|
279 000001DE B811000000 <2> mov eax, %1
|
||||||
|
280 000001E3 E960010000 <2> jmp isr_main
|
||||||
|
281 <1> isr_label 18
|
||||||
|
282 <2> isr_%1:
|
||||||
|
283 000001E8 50 <2> push eax
|
||||||
|
284 000001E9 B812000000 <2> mov eax, %1
|
||||||
|
285 000001EE E955010000 <2> jmp isr_main
|
||||||
|
286 <1> isr_label 19
|
||||||
|
287 <2> isr_%1:
|
||||||
|
288 000001F3 50 <2> push eax
|
||||||
|
289 000001F4 B813000000 <2> mov eax, %1
|
||||||
|
290 000001F9 E94A010000 <2> jmp isr_main
|
||||||
|
291 <1> isr_label 20
|
||||||
|
292 <2> isr_%1:
|
||||||
|
293 000001FE 50 <2> push eax
|
||||||
|
294 000001FF B814000000 <2> mov eax, %1
|
||||||
|
295 00000204 E93F010000 <2> jmp isr_main
|
||||||
|
296 <1> isr_label 21
|
||||||
|
297 <2> isr_%1:
|
||||||
|
298 00000209 50 <2> push eax
|
||||||
|
299 0000020A B815000000 <2> mov eax, %1
|
||||||
|
300 0000020F E934010000 <2> jmp isr_main
|
||||||
|
301 <1> isr_label 22
|
||||||
|
302 <2> isr_%1:
|
||||||
|
303 00000214 50 <2> push eax
|
||||||
|
304 00000215 B816000000 <2> mov eax, %1
|
||||||
|
305 0000021A E929010000 <2> jmp isr_main
|
||||||
|
306 <1> isr_label 23
|
||||||
|
307 <2> isr_%1:
|
||||||
|
308 0000021F 50 <2> push eax
|
||||||
|
309 00000220 B817000000 <2> mov eax, %1
|
||||||
|
310 00000225 E91E010000 <2> jmp isr_main
|
||||||
|
311 <1> isr_label 24
|
||||||
|
312 <2> isr_%1:
|
||||||
|
313 0000022A 50 <2> push eax
|
||||||
|
314 0000022B B818000000 <2> mov eax, %1
|
||||||
|
315 00000230 E913010000 <2> jmp isr_main
|
||||||
|
316 <1> isr_label 25
|
||||||
|
317 <2> isr_%1:
|
||||||
|
318 00000235 50 <2> push eax
|
||||||
|
319 00000236 B819000000 <2> mov eax, %1
|
||||||
|
320 0000023B E908010000 <2> jmp isr_main
|
||||||
|
321 <1> isr_label 26
|
||||||
|
322 <2> isr_%1:
|
||||||
|
323 00000240 50 <2> push eax
|
||||||
|
324 00000241 B81A000000 <2> mov eax, %1
|
||||||
|
325 00000246 E9FD000000 <2> jmp isr_main
|
||||||
|
326 <1> isr_label 27
|
||||||
|
327 <2> isr_%1:
|
||||||
|
328 0000024B 50 <2> push eax
|
||||||
|
329 0000024C B81B000000 <2> mov eax, %1
|
||||||
|
330 00000251 E9F2000000 <2> jmp isr_main
|
||||||
|
331 <1> isr_label 28
|
||||||
|
332 <2> isr_%1:
|
||||||
|
333 00000256 50 <2> push eax
|
||||||
|
334 00000257 B81C000000 <2> mov eax, %1
|
||||||
|
335 0000025C E9E7000000 <2> jmp isr_main
|
||||||
|
336 <1> isr_label 29
|
||||||
|
337 <2> isr_%1:
|
||||||
|
338 00000261 50 <2> push eax
|
||||||
|
339 00000262 B81D000000 <2> mov eax, %1
|
||||||
|
340 00000267 E9DC000000 <2> jmp isr_main
|
||||||
|
341 <1> isr_label 30
|
||||||
|
342 <2> isr_%1:
|
||||||
|
343 0000026C 50 <2> push eax
|
||||||
|
344 0000026D B81E000000 <2> mov eax, %1
|
||||||
|
345 00000272 E9D1000000 <2> jmp isr_main
|
||||||
|
346 <1> isr_label 31
|
||||||
|
347 <2> isr_%1:
|
||||||
|
348 00000277 50 <2> push eax
|
||||||
|
349 00000278 B81F000000 <2> mov eax, %1
|
||||||
|
350 0000027D E9C6000000 <2> jmp isr_main
|
||||||
|
351 <1> isr_label 32
|
||||||
|
352 <2> isr_%1:
|
||||||
|
353 00000282 50 <2> push eax
|
||||||
|
354 00000283 B820000000 <2> mov eax, %1
|
||||||
|
355 00000288 E9BB000000 <2> jmp isr_main
|
||||||
|
356 <1> isr_label 33
|
||||||
|
357 <2> isr_%1:
|
||||||
|
358 0000028D 50 <2> push eax
|
||||||
|
359 0000028E B821000000 <2> mov eax, %1
|
||||||
|
360 00000293 E9B0000000 <2> jmp isr_main
|
||||||
|
361 <1> isr_label 34
|
||||||
|
362 <2> isr_%1:
|
||||||
|
363 00000298 50 <2> push eax
|
||||||
|
364 00000299 B822000000 <2> mov eax, %1
|
||||||
|
365 0000029E E9A5000000 <2> jmp isr_main
|
||||||
|
366 <1> isr_label 35
|
||||||
|
367 <2> isr_%1:
|
||||||
|
368 000002A3 50 <2> push eax
|
||||||
|
369 000002A4 B823000000 <2> mov eax, %1
|
||||||
|
370 000002A9 E99A000000 <2> jmp isr_main
|
||||||
|
371 <1> isr_label 36
|
||||||
|
372 <2> isr_%1:
|
||||||
|
373 000002AE 50 <2> push eax
|
||||||
|
374 000002AF B824000000 <2> mov eax, %1
|
||||||
|
375 000002B4 E98F000000 <2> jmp isr_main
|
||||||
|
376 <1> isr_label 37
|
||||||
|
377 <2> isr_%1:
|
||||||
|
378 000002B9 50 <2> push eax
|
||||||
|
379 000002BA B825000000 <2> mov eax, %1
|
||||||
|
380 000002BF E984000000 <2> jmp isr_main
|
||||||
|
381 <1> isr_label 38
|
||||||
|
382 <2> isr_%1:
|
||||||
|
383 000002C4 50 <2> push eax
|
||||||
|
384 000002C5 B826000000 <2> mov eax, %1
|
||||||
|
385 000002CA E979000000 <2> jmp isr_main
|
||||||
|
386 <1> isr_label 39
|
||||||
|
387 <2> isr_%1:
|
||||||
|
388 000002CF 50 <2> push eax
|
||||||
|
389 000002D0 B827000000 <2> mov eax, %1
|
||||||
|
390 000002D5 E96E000000 <2> jmp isr_main
|
||||||
|
391 <1> isr_label 40
|
||||||
|
392 <2> isr_%1:
|
||||||
|
393 000002DA 50 <2> push eax
|
||||||
|
394 000002DB B828000000 <2> mov eax, %1
|
||||||
|
395 000002E0 E963000000 <2> jmp isr_main
|
||||||
|
396 <1> isr_label 41
|
||||||
|
397 <2> isr_%1:
|
||||||
|
398 000002E5 50 <2> push eax
|
||||||
|
399 000002E6 B829000000 <2> mov eax, %1
|
||||||
|
400 000002EB E958000000 <2> jmp isr_main
|
||||||
|
401 <1> isr_label 42
|
||||||
|
402 <2> isr_%1:
|
||||||
|
403 000002F0 50 <2> push eax
|
||||||
|
404 000002F1 B82A000000 <2> mov eax, %1
|
||||||
|
405 000002F6 E94D000000 <2> jmp isr_main
|
||||||
|
406 <1> isr_label 43
|
||||||
|
407 <2> isr_%1:
|
||||||
|
408 000002FB 50 <2> push eax
|
||||||
|
409 000002FC B82B000000 <2> mov eax, %1
|
||||||
|
410 00000301 E942000000 <2> jmp isr_main
|
||||||
|
411 <1> isr_label 44
|
||||||
|
412 <2> isr_%1:
|
||||||
|
413 00000306 50 <2> push eax
|
||||||
|
414 00000307 B82C000000 <2> mov eax, %1
|
||||||
|
415 0000030C E937000000 <2> jmp isr_main
|
||||||
|
416 <1> isr_label 45
|
||||||
|
417 <2> isr_%1:
|
||||||
|
418 00000311 50 <2> push eax
|
||||||
|
419 00000312 B82D000000 <2> mov eax, %1
|
||||||
|
420 00000317 E92C000000 <2> jmp isr_main
|
||||||
|
421 <1> isr_label 46
|
||||||
|
422 <2> isr_%1:
|
||||||
|
423 0000031C 50 <2> push eax
|
||||||
|
424 0000031D B82E000000 <2> mov eax, %1
|
||||||
|
425 00000322 E921000000 <2> jmp isr_main
|
||||||
|
426 <1> isr_label 47
|
||||||
|
427 <2> isr_%1:
|
||||||
|
428 00000327 50 <2> push eax
|
||||||
|
429 00000328 B82F000000 <2> mov eax, %1
|
||||||
|
430 0000032D E916000000 <2> jmp isr_main
|
||||||
|
431 <1> isr_label 48
|
||||||
|
432 <2> isr_%1:
|
||||||
|
433 00000332 50 <2> push eax
|
||||||
|
434 00000333 B830000000 <2> mov eax, %1
|
||||||
|
435 00000338 E90B000000 <2> jmp isr_main
|
||||||
|
436 <1> isr_label 49
|
||||||
|
437 <2> isr_%1:
|
||||||
|
438 0000033D 50 <2> push eax
|
||||||
|
439 0000033E B831000000 <2> mov eax, %1
|
||||||
|
440 00000343 E900000000 <2> jmp isr_main
|
||||||
|
441 <1>
|
||||||
|
442 <1> isr_main:
|
||||||
|
443 00000348 3D30000000 <1> cmp eax, 0x30
|
||||||
|
444 0000034D 7414 <1> jz isr_syscall
|
||||||
|
445 <1>
|
||||||
|
446 0000034F 60 <1> pusha
|
||||||
|
447 00000350 1E <1> push ds
|
||||||
|
448 00000351 06 <1> push es
|
||||||
|
449 <1>
|
||||||
|
450 00000352 50 <1> push eax
|
||||||
|
451 <1>
|
||||||
|
452 00000353 E8(00000000) <1> call _isr
|
||||||
|
453 <1>
|
||||||
|
454 00000358 81C404000000 <1> add esp, 4
|
||||||
|
455 <1>
|
||||||
|
456 0000035E 07 <1> pop es
|
||||||
|
457 0000035F 1F <1> pop ds
|
||||||
|
458 00000360 61 <1> popa
|
||||||
|
459 00000361 58 <1> pop eax
|
||||||
|
460 <1>
|
||||||
|
461 00000362 CF <1> iret
|
||||||
|
462 <1>
|
||||||
|
463 <1>
|
||||||
|
464 <1> isr_syscall:
|
||||||
|
465 00000363 58 <1> pop eax ;syscall function number
|
||||||
|
466 00000364 60 <1> pusha
|
||||||
|
467 00000365 1E <1> push ds
|
||||||
|
468 00000366 06 <1> push es
|
||||||
|
469 <1>
|
||||||
|
470 <1> sc1:
|
||||||
|
471 00000367 3D01000000 <1> cmp eax, 1 ;syscall 1 - putc
|
||||||
|
472 0000036C 7511 <1> jnz sc2
|
||||||
|
473 0000036E 53 <1> push ebx
|
||||||
|
474 0000036F E8(00000000) <1> call _putc
|
||||||
|
475 00000374 81C404000000 <1> add esp, 4
|
||||||
|
476 0000037A E900000000 <1> jmp scdone
|
||||||
|
477 <1> sc2:
|
||||||
|
478 <1>
|
||||||
|
479 <1> scdone:
|
||||||
|
480 0000037F 07 <1> pop es
|
||||||
|
481 00000380 1F <1> pop ds
|
||||||
|
482 00000381 61 <1> popa
|
||||||
|
483 00000382 CF <1> iret
|
||||||
|
484 <1>
|
||||||
|
485 <1>
|
||||||
|
486 <1>
|
||||||
|
487 <1>
|
||||||
|
488 <1>
|
||||||
|
489 <1>
|
||||||
|
490 <1>
|
||||||
|
491
|
||||||
|
492
|
@ -68,13 +68,13 @@ void video_horiz(int y, int x1, int x2, dword color)
|
|||||||
}
|
}
|
||||||
if (x2 < 0)
|
if (x2 < 0)
|
||||||
return;
|
return;
|
||||||
if (x1 > video_mode.XResolution)
|
if (x1 >= video_mode.XResolution)
|
||||||
return;
|
return;
|
||||||
if (x1 < 0)
|
if (x1 < 0)
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
if (x2 > video_mode.XResolution)
|
if (x2 >= video_mode.XResolution)
|
||||||
x2 = video_mode.XResolution;
|
x2 = video_mode.XResolution - 1;
|
||||||
int pixel = y*video_mode.XResolution+x1;
|
int pixel = y * video_mode.XResolution + x1;
|
||||||
for (; x1 <= x2; x1++)
|
for (; x1 <= x2; x1++)
|
||||||
{
|
{
|
||||||
video_psetp(pixel++, color);
|
video_psetp(pixel++, color);
|
||||||
@ -84,12 +84,13 @@ void video_horiz(int y, int x1, int x2, dword color)
|
|||||||
//Draws a single pixel
|
//Draws a single pixel
|
||||||
void video_pset(int x, int y, dword color)
|
void video_pset(int x, int y, dword color)
|
||||||
{
|
{
|
||||||
if ((x < 0) || (x > video_mode.XResolution) || (y < 0) || (y > video_mode.YResolution))
|
if ((x < 0) || (x >= video_mode.XResolution) || (y < 0) || (y >= video_mode.YResolution))
|
||||||
return;
|
return;
|
||||||
video_psetp(y*video_mode.XResolution+x, color);
|
video_psetp(y * video_mode.XResolution + x, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draws a pixel at the specified pixel position
|
//Draws a pixel at the specified pixel position
|
||||||
|
//This function is needed because external modules do not have access to the function pointer video_psetp
|
||||||
void video_pseti(int pixel, dword color)
|
void video_pseti(int pixel, dword color)
|
||||||
{
|
{
|
||||||
video_psetp(pixel, color);
|
video_psetp(pixel, color);
|
||||||
@ -106,17 +107,17 @@ void video_vert(int x, int y1, int y2, dword color)
|
|||||||
}
|
}
|
||||||
if (y2 < 0)
|
if (y2 < 0)
|
||||||
return;
|
return;
|
||||||
if (y1 > video_mode.YResolution)
|
if (y1 >= video_mode.YResolution)
|
||||||
return;
|
return;
|
||||||
if (y1 < 0)
|
if (y1 < 0)
|
||||||
y1 = 0;
|
y1 = 0;
|
||||||
if (y2 > video_mode.YResolution)
|
if (y2 >= video_mode.YResolution)
|
||||||
y2 = video_mode.YResolution;
|
y2 = video_mode.YResolution - 1;
|
||||||
int pixel = y1*video_mode.XResolution+x;
|
int pixel = y1 * video_mode.XResolution + x;
|
||||||
for (; y1 <= y2; y1++)
|
for (; y1 <= y2; y1++)
|
||||||
{
|
{
|
||||||
video_psetp(pixel, color);
|
video_psetp(pixel, color);
|
||||||
pixel+=video_mode.XResolution;
|
pixel += video_mode.XResolution;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,3 +192,63 @@ dword video_Mode()
|
|||||||
return videoMode;
|
return videoMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void video_line(int x0, int y0, int x1, int y1, dword color)
|
||||||
|
{
|
||||||
|
int dy = y1 - y0;
|
||||||
|
int dx = x1 - x0;
|
||||||
|
int stepx, stepy;
|
||||||
|
if (dy < 0)
|
||||||
|
{
|
||||||
|
dy = -dy;
|
||||||
|
stepy = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stepy = 1;
|
||||||
|
}
|
||||||
|
if (dx < 0)
|
||||||
|
{
|
||||||
|
dx = -dx;
|
||||||
|
stepx = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stepx = 1;
|
||||||
|
}
|
||||||
|
dy <<= 1; // dy is now 2*dy
|
||||||
|
dx <<= 1; // dx is now 2*dx
|
||||||
|
video_pset(x0, y0, color);
|
||||||
|
|
||||||
|
if (dx > dy)
|
||||||
|
{
|
||||||
|
int fraction = dy - (dx >> 1); // same as 2*dy - dx
|
||||||
|
while (x0 != x1)
|
||||||
|
{
|
||||||
|
if (fraction >= 0)
|
||||||
|
{
|
||||||
|
y0 += stepy;
|
||||||
|
fraction -= dx; // same as fraction -= 2*dx
|
||||||
|
}
|
||||||
|
x0 += stepx;
|
||||||
|
fraction += dy; // same as fraction -= 2*dy
|
||||||
|
video_pset(x0, y0, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int fraction = dx - (dy >> 1);
|
||||||
|
while (y0 != y1)
|
||||||
|
{
|
||||||
|
if (fraction >= 0)
|
||||||
|
{
|
||||||
|
x0 += stepx;
|
||||||
|
fraction -= dy;
|
||||||
|
}
|
||||||
|
y0 += stepy;
|
||||||
|
fraction += dx;
|
||||||
|
video_pset(x0, y0, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ int video_getHeight();
|
|||||||
byte video_getBitsPerPixel();
|
byte video_getBitsPerPixel();
|
||||||
dword video_getPhysBasePtr();
|
dword video_getPhysBasePtr();
|
||||||
dword video_Mode();
|
dword video_Mode();
|
||||||
|
void video_line(int x0, int y0, int x1, int y1, dword color);
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
39
readme.txt
39
readme.txt
@ -11,42 +11,7 @@ Change Log
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
0.14
|
0.14
|
||||||
|
03/16/04 - new VFS design with support for a loop device
|
||||||
03/01/04 - Thanks to Ben Meyer for helping me get a Makefile working and building on linux to work!
|
03/01/04 - Thanks to Ben Meyer for helping me get a Makefile working and building on linux to work!
|
||||||
|
|
||||||
0.13
|
0.1301/26/04 - functions added to read/write CMOS clock date and time01/19/04 - fixed bug GDTR/IDTR pointing to physical rather than linear table base address01/07/04 - fixed bug not reading sectors correctly from floppy12/28/03 - fixed bug not storing eax on interrupt12/25/03 - fixed bug in mm_palloc()12/25/03 - incorporated output functions as regular functions rather than as part of a linked library12/23/03 - re-written physical memory manager using bitmap instead of stack12/22/03 - kernel relocated to 3gb linear / 1mb+24kb physical to allow for app. address space0.1212/21/03 - sample bmp loader tested, works (tests loading a kernel of size ~ 932kb12/20/03 - GDT/IDT now located at 1mb physical, before kernel10/30/03 - turns floppy motor off10/30/03 - keyboard LEDs working10/29/03 - paging functions working10/15/03 - physical memory management page allocators working0.1110/09/03 - PS/2 mouse driver0.1009/11/03 - Rewritten C and assembly kernel with VESA GUI mode support, keyboard driver0.0505/14/03 - HGUI24/HGUI32 commands finished for testing GUI on both 24bpp and 32bpp graphics cards05/14/03 - first web release!0.0403/09/03 - added VM shortcut command03/09/03 - press up to fill retrieve last inputted command for Nate Scholten03/08/03 - press clear to clear console input03/07/03 - added "shortcut" commands PC, IC, ? for Nate Scholten03/06/03 - added PROMPTC, INPUTC commands0.0312/30/02 - Command Line Interface working, accepting basic commands
|
||||||
01/26/04 - functions added to read/write CMOS clock date and time
|
|
||||||
01/19/04 - fixed bug GDTR/IDTR pointing to physical rather than linear table base address
|
|
||||||
01/07/04 - fixed bug not reading sectors correctly from floppy
|
|
||||||
12/28/03 - fixed bug not storing eax on interrupt
|
|
||||||
12/25/03 - fixed bug in mm_palloc()
|
|
||||||
12/25/03 - incorporated output functions as regular functions rather than as part of a linked library
|
|
||||||
12/23/03 - re-written physical memory manager using bitmap instead of stack
|
|
||||||
12/22/03 - kernel relocated to 3gb linear / 1mb+24kb physical to allow for app. address space
|
|
||||||
|
|
||||||
0.12
|
|
||||||
12/21/03 - sample bmp loader tested, works (tests loading a kernel of size ~ 932kb
|
|
||||||
12/20/03 - GDT/IDT now located at 1mb physical, before kernel
|
|
||||||
10/30/03 - turns floppy motor off
|
|
||||||
10/30/03 - keyboard LEDs working
|
|
||||||
10/29/03 - paging functions working
|
|
||||||
10/15/03 - physical memory management page allocators working
|
|
||||||
|
|
||||||
0.11
|
|
||||||
10/09/03 - PS/2 mouse driver
|
|
||||||
|
|
||||||
0.10
|
|
||||||
09/11/03 - Rewritten C and assembly kernel with VESA GUI mode support, keyboard driver
|
|
||||||
|
|
||||||
0.05
|
|
||||||
05/14/03 - HGUI24/HGUI32 commands finished for testing GUI on both 24bpp and 32bpp graphics cards
|
|
||||||
05/14/03 - first web release!
|
|
||||||
|
|
||||||
0.04
|
|
||||||
03/09/03 - added VM shortcut command
|
|
||||||
03/09/03 - press up to fill retrieve last inputted command for Nate Scholten
|
|
||||||
03/08/03 - press clear to clear console input
|
|
||||||
03/07/03 - added "shortcut" commands PC, IC, ? for Nate Scholten
|
|
||||||
03/06/03 - added PROMPTC, INPUTC commands
|
|
||||||
|
|
||||||
0.03
|
|
||||||
12/30/02 - Command Line Interface working, accepting basic commands
|
|
Loading…
x
Reference in New Issue
Block a user