Merge branch 'master' into TweetNaCL

This commit is contained in:
y4my4my4m 2025-02-09 18:44:27 +09:00 committed by GitHub
commit 1f12b9d20d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 564 additions and 168 deletions

69
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,69 @@
name: Build ZealOS ISOs
on:
push:
branches:
- 'master'
paths-ignore:
- '**.md'
- 'screenshots/**'
- '**/LICENSE'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'
- 'screenshots/**'
- '**/LICENSE'
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Install Dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install build-essential git xorriso qemu-system-x86
- name: Enable KVM Group Perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run ISOs Build Script
timeout-minutes: 10
if: ${{ success() }}
run: |
cd build
./build-iso.sh --headless
cd ..
- name: ISO Check
if: ${{ success() && hashFiles('./build/*.iso') == '' }}
run: |
echo "ISOs not built!"
exit 1
- name: Releasing Latest ISOs
if: ${{ success() && github.event_name == 'push'}}
uses: "GutPuncher/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: false
title: "Pre-Built ISOs [${{ github.sha }}]"
files: ./build/*.iso
- name: OK
if: ${{ success() }}
run: |
echo "Build OK"

View File

@ -1,6 +1,6 @@
# ZealOS # ZealOS
[![Discord](https://img.shields.io/discord/934200098144022609?color=7289DA&label=Discord&logo=discord&logoColor=white)](https://discord.gg/rK6U3xdr7D) [![](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://zeal-operating-system.github.io/ZealOS-wiki/) [![Discord](https://img.shields.io/discord/934200098144022609?color=7289DA&label=Discord&logo=discord&logoColor=white)](https://discord.gg/rK6U3xdr7D) [![](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://zeal-operating-system.github.io/ZealOS-wiki/) [![Build ZealOS ISOs](https://github.com/Zeal-Operating-System/ZealOS/actions/workflows/build.yml/badge.svg)](https://github.com/Zeal-Operating-System/ZealOS/actions/workflows/build.yml)
The Zeal Operating System is a modernized fork of the 64-bit Temple Operating System. Guiding principles of development include transparency, full user control, and adherence to public-domain/open-source implementations. The Zeal Operating System is a modernized fork of the 64-bit Temple Operating System. Guiding principles of development include transparency, full user control, and adherence to public-domain/open-source implementations.
@ -14,7 +14,7 @@ Features in development include:
- [32-bit color VBE graphics](https://github.com/TempleProgramming/HolyGL) - [32-bit color VBE graphics](https://github.com/TempleProgramming/HolyGL)
- Fully-functional AHCI support - Fully-functional AHCI support
- Network card drivers and a networking stack - Network card drivers and a networking stack
- UEFI booting via [BSD2-licensed Limine bootloader](https://github.com/limine-bootloader/limine) and [Public Domain ZealBooter prekernel](/zealbooter/zealbooter.c) - UEFI booting via [BSD2-licensed Limine bootloader](https://github.com/limine-bootloader/limine) and [Public Domain ZealBooter prekernel](/zealbooter/src/zealbooter.c)
[Changes include](https://zeal-operating-system.github.io/Doc/ChangeLog.DD.html): [Changes include](https://zeal-operating-system.github.io/Doc/ChangeLog.DD.html):
- 60 FPS - 60 FPS

Binary file not shown.

View File

@ -13,8 +13,10 @@ then
exit exit
fi fi
# Uncomment if you use doas instead of sudo [ "$1" = "--headless" ] && QEMU_HEADLESS='-display none'
#alias sudo=doas
KVM=''
(lsmod | grep -q kvm) && KVM=' -accel kvm'
# Set this true if you want to test ISOs in QEMU after building. # Set this true if you want to test ISOs in QEMU after building.
TESTING=false TESTING=false
@ -50,7 +52,7 @@ set +e
echo "Making temp vdisk, running auto-install ..." echo "Making temp vdisk, running auto-install ..."
$QEMU_BIN_PATH/qemu-img create -f raw $TMPDISK 1024M $QEMU_BIN_PATH/qemu-img create -f raw $TMPDISK 1024M
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -cdrom AUTO.ISO -device isa-debug-exit $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -cdrom AUTO.ISO -device isa-debug-exit $QEMU_HEADLESS
echo "Copying all src/ code into vdisk Tmp/OSBuild/ ..." echo "Copying all src/ code into vdisk Tmp/OSBuild/ ..."
rm ../src/Home/Registry.ZC 2> /dev/null rm ../src/Home/Registry.ZC 2> /dev/null
@ -62,9 +64,9 @@ sudo cp -r ../src/* $TMPMOUNT/Tmp/OSBuild
umount_tempdisk umount_tempdisk
echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..." echo "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -drive format=raw,file=$TMPDISK -m 1G -rtc base=localtime -smp 4 -device isa-debug-exit $QEMU_HEADLESS
LIMINE_BINARY_BRANCH="v6.x-branch-binary" LIMINE_BINARY_BRANCH="v8.x-binary"
if [ -d "limine" ] if [ -d "limine" ]
then then
@ -73,6 +75,8 @@ then
git fetch git fetch
git remote set-head origin $LIMINE_BINARY_BRANCH git remote set-head origin $LIMINE_BINARY_BRANCH
git switch $LIMINE_BINARY_BRANCH git switch $LIMINE_BINARY_BRANCH
git config --local pull.ff true
git config --local pull.rebase true
git pull git pull
rm limine rm limine
@ -106,7 +110,7 @@ sudo cp limine/limine-uefi-cd.bin $TMPISODIR/Boot/Limine-UEFI-CD.BIN
sudo cp limine/limine-bios-cd.bin $TMPISODIR/Boot/Limine-BIOS-CD.BIN sudo cp limine/limine-bios-cd.bin $TMPISODIR/Boot/Limine-BIOS-CD.BIN
sudo cp limine/limine-bios.sys $TMPISODIR/Boot/Limine-BIOS.SYS sudo cp limine/limine-bios.sys $TMPISODIR/Boot/Limine-BIOS.SYS
sudo cp ../zealbooter/bin/kernel $TMPISODIR/Boot/ZealBooter.ELF sudo cp ../zealbooter/bin/kernel $TMPISODIR/Boot/ZealBooter.ELF
sudo cp ../zealbooter/Limine.CFG $TMPISODIR/Boot/Limine.CFG sudo cp ../zealbooter/limine.conf $TMPISODIR/Boot/Limine.CONF
echo "Copying DVDKernel.ZXE over ISO Boot/Kernel.ZXE ..." echo "Copying DVDKernel.ZXE over ISO Boot/Kernel.ZXE ..."
sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE sudo mv $TMPMOUNT/Tmp/DVDKernel.ZXE $TMPISODIR/Boot/Kernel.ZXE
sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null sudo rm $TMPISODIR/Tmp/DVDKernel.ZXE 2> /dev/null
@ -130,11 +134,11 @@ if [ "$TESTING" = true ]; then
cd .. cd ..
fi fi
echo "Testing limine-zealbooter-xorriso isohybrid boot in UEFI mode ..." echo "Testing limine-zealbooter-xorriso isohybrid boot in UEFI mode ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -m 1G -rtc base=localtime -bios ovmf/OVMF.fd -smp 4 -cdrom ZealOS-limine.iso $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -m 1G -rtc base=localtime -bios ovmf/OVMF.fd -smp 4 -cdrom ZealOS-limine.iso $QEMU_HEADLESS
echo "Testing limine-zealbooter-xorriso isohybrid boot in BIOS mode ..." echo "Testing limine-zealbooter-xorriso isohybrid boot in BIOS mode ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -m 1G -rtc base=localtime -smp 4 -cdrom ZealOS-limine.iso $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -m 1G -rtc base=localtime -smp 4 -cdrom ZealOS-limine.iso $QEMU_HEADLESS
echo "Testing native ZealC MyDistro legacy ISO in BIOS mode ..." echo "Testing native ZealC MyDistro legacy ISO in BIOS mode ..."
$QEMU_BIN_PATH/qemu-system-x86_64 -machine q35,accel=kvm -m 1G -rtc base=localtime -smp 4 -cdrom ZealOS-MyDistro.iso $QEMU_BIN_PATH/qemu-system-x86_64 -machine q35 $KVM -m 1G -rtc base=localtime -smp 4 -cdrom ZealOS-MyDistro.iso $QEMU_HEADLESS
fi fi
# comment these 2 lines if you want lingering old Distro ISOs # comment these 2 lines if you want lingering old Distro ISOs

View File

@ -15,7 +15,7 @@ read -p "Enter fork branch name: " FORK_BRANCH
echo $FORK_BRANCH echo $FORK_BRANCH
FORK_LOCAL=$FORK_BRANCH"-testing" FORK_LOCAL=$FORK_BRANCH"-testing"
echo "Creating new local branch for testing: "$FORK_LOCAL" ..." echo "Creating new local branch for testing: "$FORK_LOCAL" ..."
git checkout -b $FORK_LOCAL git checkout -B $FORK_LOCAL
echo "Pulling changes from user's branch into new local branch..." echo "Pulling changes from user's branch into new local branch..."
git pull https://github.com/$FORK_USERNAME/ZealOS.git $FORK_BRANCH git pull https://github.com/$FORK_USERNAME/ZealOS.git $FORK_BRANCH

View File

@ -44,9 +44,10 @@ DOCS_DIR=
TMPMOUNT=/tmp/zealtmp TMPMOUNT=/tmp/zealtmp
print_usage() { print_usage() {
echo "Usage: $0 ( repo | vm ) [OPTION]" echo "Usage: $0 ( repo | vm | diff ) [OPTION]"
echo " repo Overwrites src/ with virtual disk contents." echo " repo Overwrites src/ with virtual disk contents."
echo " vm Overwrites virtual disk with src/ contents." echo " vm Overwrites virtual disk with src/ contents."
echo " diff Runs a 'diff' between src/ and virtual disk."
echo "Options:" echo "Options:"
echo " --ignore-dots Ignore dotfiles/dotfolders during synchronize." echo " --ignore-dots Ignore dotfiles/dotfolders during synchronize."
} }
@ -73,6 +74,18 @@ else
sudo modprobe nbd sudo modprobe nbd
[ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT [ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT
case $1 in case $1 in
flush)
mount_vdisk
sudo blockdev --flushbufs /dev/nbd0
sudo dosfsck -w -r -l -v -t /dev/nbd0
umount_vdisk
;;
diff)
mount_vdisk
diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*"
umount_vdisk
echo "Finished."
;;
repo) repo)
echo "Emptying src..." echo "Emptying src..."
rm -rf ../src/* rm -rf ../src/*
@ -90,6 +103,7 @@ else
umount_vdisk umount_vdisk
[ -f ../src/Tmp/AUTO.ISO.C ] && mv ../src/Tmp/AUTO.ISO.C ./AUTO.ISO [ -f ../src/Tmp/AUTO.ISO.C ] && mv ../src/Tmp/AUTO.ISO.C ./AUTO.ISO
echo "Finished." echo "Finished."
cd ../
git status git status
;; ;;
vm) vm)

View File

@ -664,18 +664,25 @@ I64 MoveCnt(GameState *state)
{ {
I64 i, res = 0, mv_cnt; I64 i, res = 0, mv_cnt;
Move mvs[32]; Move mvs[32];
Bool king_stalemate = TRUE;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{
if (state->pieces[i].player == state->cur_player) if (state->pieces[i].player == state->cur_player)
{ {
mv_cnt = PieceMoves(state, i, mvs); mv_cnt = PieceMoves(state, i, mvs);
mv_cnt = ChkPieceMoves(state, i, mvs,mv_cnt); mv_cnt = ChkPieceMoves(state, i, mvs,mv_cnt);
res += mv_cnt; res += mv_cnt;
} }
if (state->pieces[i].type != P_KING && state->pieces[i].player >= 0)
king_stalemate = FALSE;
}
if (king_stalemate)
return 0;
else
return res; return res;
} }
U0 DrawIt(CTask *task, CDC *dc) U0 DrawIt(CTask *task, CDC *dc)
{ {
I64 i, x, y, z, k0, k1; I64 i, x, y, z, k0, k1;

View File

@ -4,7 +4,7 @@
I0 DrawPixel(I64 x, I64 y, CBGR24 color) I0 DrawPixel(I64 x, I64 y, CBGR24 color)
{ {
text.fb_alias[x + y * GR_WIDTH] = color; text.fb_alias[x + y * sys_framebuffer_width] = color;
} }
I0 Color32Demo() I0 Color32Demo()

View File

@ -32,12 +32,12 @@ U0 PaintGlobalsInit()
I0 DrawImagePixel(I64 x, I64 y, CBGR24 color) I0 DrawImagePixel(I64 x, I64 y, CBGR24 color)
{ {
paint.fb[x + y * GR_WIDTH] = color; paint.fb[x + y * sys_framebuffer_width] = color;
} }
I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color) I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color)
{ {
text.fb_alias[x + y * GR_WIDTH] = color; text.fb_alias[x + y * sys_framebuffer_width] = color;
} }
I0 DrawScreenChar(I64 x, I64 y, I64 char) I0 DrawScreenChar(I64 x, I64 y, I64 char)
@ -136,7 +136,7 @@ U0 PaintLoadImage()
U32 PaintImagePeek(I64 x, I64 y) U32 PaintImagePeek(I64 x, I64 y)
{ {
return paint.fb[x + y * GR_WIDTH]; return paint.fb[x + y * sys_framebuffer_width];
} }
I0 Paint32() I0 Paint32()
@ -176,7 +176,7 @@ I0 Paint32()
// draw the image where the brush was last covering it // draw the image where the brush was last covering it
for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++) for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++)
for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++) for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++)
DrawScreenPixel(i, j, paint.fb[i + j * GR_WIDTH]); DrawScreenPixel(i, j, paint.fb[i + j * sys_framebuffer_width]);
// draw the brush on the screen // draw the brush on the screen
DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick); DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick);
@ -193,7 +193,7 @@ I0 Paint32()
// draw the image where the color strings where covering it // draw the image where the color strings where covering it
for (i = 0; i < 3 * FONT_HEIGHT; i++) for (i = 0; i < 3 * FONT_HEIGHT; i++)
for (j = 0; j < 12 * FONT_WIDTH; j++) for (j = 0; j < 12 * FONT_WIDTH; j++)
DrawScreenPixel(j, i, paint.fb[j + i * GR_WIDTH]); DrawScreenPixel(j, i, paint.fb[j + i * sys_framebuffer_width]);
// draw the color strings on screen // draw the color strings on screen
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r); DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);

219
src/Demo/Graphics/Mandel.ZC Normal file
View File

@ -0,0 +1,219 @@
// Mandelbrot set explorer (multi-core).
//
// - Click-and drag to move around.
// - PGUP/PGDN to zoom
// - HOME/END to increase/decrease iterations
// - ESC to exit
I64 width = GR_WIDTH;
I64 height = GR_HEIGHT;
I64 iterations = 24;
F64 xCenter = -0.5, yCenter = 0.0;
F64 xExtent = 3.0;
I64 numCores = mp_count - 1;
// -------------------
CDC* image;
I64 rowsPerCore = height / numCores;
I64 currentSequence;
U0 MandelFrame(I64 core)
{
// CDC* dc = DCAlias(image);
I64 mySequence = currentSequence;
I64 startX = 0;
I64 maxX = startX + width;
I64 startY = core * rowsPerCore;
I64 maxY = startY + rowsPerCore;
F64 xmin = xCenter - (xExtent / 2.0);
F64 xmax = xmin + xExtent;
F64 aspect = ToF64(width) / ToF64(height);
F64 ymin = yCenter - (xExtent / aspect / 2.0);
F64 ymax = ymin + (xExtent / aspect);
F64 x, y, x0, y0, x2, y2;
F64 xscale = (xmax - xmin) / ToF64(width);
F64 yscale = (ymax - ymin) / ToF64(height);
I64 iteration;
I64 px, py;
for (py = startY; py < maxY; py++) {
y0 = ymin + ToF64(py) * yscale;
if (mySequence != currentSequence)
break;
for (px = startX; px < maxX; px++) {
x = 0.0; y = 0.0;
x2 = 0.0; y2 = 0.0;
iteration = 0;
x0 = xmin + ToF64(px) * xscale;
while ((x2 + y2) < 4.0) {
y = (2.0 *x * y) + y0;
x = x2 - y2 + x0;
x2 = x * x;
y2 = y * y;
if (++iteration > iterations) {
break;
}
}
/*
if (iteration >= iterations) {
dc->color = BLACK;
} else {
dc->color = iteration & 15;
}
GrPlot0(dc, px, py);
*/
// Instead of getting a DC handle
// every time, we can just poke
// into the body of the DC.
// (is that ok?)
if (iteration >= iterations)
image->body[py*width+px] = 15;
else
image->body[py*width+px] = iteration % 15;
}
}
// DCDel(dc);
}
U0 DrawIt(CTask *task, CDC *dc) {
image->flags |= DCF_NO_TRANSPARENTS;
GrBlot(dc, 0, 0, image);
}
U0 Mandel() {
SettingsPush;
AutoComplete;
WinBorder;
WinMax;
DocClear;
DCFill;
Fs->win_inhibit = WIG_TASK_DEFAULT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
I64 msg_code, arg1, arg2;
I64 i, j, lastx, lasty;
F64 aspect;
Bool moving = FALSE;
Bool renderFrame = TRUE;
// Make our own palette, if we like.
CBGR48 bgr;
for (i=0; i<COLORS_NUM; i++) {
j = 0xFFFF * i / (COLORS_NUM-1);
bgr.b = j;
bgr.g = j;
bgr.r = j;
// GrPaletteColorSet(i,bgr);
}
image = DCNew(width, height);
Fs->draw_it = &DrawIt;
while(TRUE) {
if (renderFrame) {
renderFrame = FALSE;
currentSequence++;
for (i=0; i<numCores; i++) {
JobQueue(&MandelFrame, i, i+1);
}
}
msg_code = MessageGet(&arg1, &arg2,
1<<MESSAGE_KEY_DOWN + 1<<MESSAGE_MS_L_DOWN
+ 1<<MESSAGE_MS_L_UP + 1<<MESSAGE_MS_MOVE);
switch(msg_code) {
case MESSAGE_MS_MOVE:
if (moving) {
renderFrame = TRUE;
xCenter += (xExtent / ToF64(width) * ToF64(lastx - arg1));
aspect = ToF64(width) / ToF64(height);
yCenter += (xExtent / aspect / ToF64(height) * (lasty - arg2));
}
lastx = arg1;
lasty = arg2;
break;
case MESSAGE_MS_L_DOWN:
moving = TRUE;
break;
case MESSAGE_MS_L_UP:
moving = FALSE;
break;
case MESSAGE_KEY_DOWN:
switch(arg1) {
case 0:
U8 code = arg2.u8[0];
if (code == SC_PAGE_UP ||code == SC_PAGE_DOWN) {
F64 factor = 0.6666666;
if (code == SC_PAGE_DOWN) {
factor = 1.5;
}
aspect = ToF64(width) / ToF64(height);
F64 xmin = xCenter - (xExtent / 2.0);
F64 xmax = xmin + xExtent;
F64 xpos = xmin + (ToF64(lastx)*xExtent / ToF64(width));
F64 ymin = yCenter - (xExtent / aspect / 2.0);
F64 ymax = ymin + (xExtent / aspect);
F64 ypos = ymin + (ToF64(lasty) * xExtent / aspect / ToF64(height));
xmin = xpos - (xpos - xmin)*factor;
xmax = xpos + (xmax - xpos)*factor;
ymin = ypos - (ypos - ymin)*factor;
ymax = ypos = (ymax - ypos)*factor;
xExtent = xmax - xmin;
xCenter = xmin + xExtent/2.0;
yCenter = ymin + xExtent/aspect/2.0;
renderFrame = TRUE;
}
else if(code == SC_HOME) {
iterations++;
renderFrame = TRUE;
}
else if(code == SC_END) {
iterations--;
if (iterations < 2)
iterations = 2;
renderFrame = TRUE;
}
break;
case CH_ESC:
case CH_SHIFT_ESC:
goto m_done;
default:
break;
}
break;
default:
break;
}
}
m_done:
DCDel(image);
DCFill;
SettingsPop;
}
Mandel;

View File

@ -59,6 +59,7 @@
#define PCNET_INT_TINTM 9 // Transmit Interrupt Mask #define PCNET_INT_TINTM 9 // Transmit Interrupt Mask
#define PCNET_INT_RINTM 10 // Receive Interrupt Mask #define PCNET_INT_RINTM 10 // Receive Interrupt Mask
#define PCNET_FEATURE_ASTRPRCV 10
#define PCNET_FEATURE_APADXMT 11 #define PCNET_FEATURE_APADXMT 11
#define PCNET_BCR_MISC_CONFIG_ASEL 1 #define PCNET_BCR_MISC_CONFIG_ASEL 1
@ -455,7 +456,7 @@ U0 PCNetInterruptCSRSet()
U0 PCNetTXAutoPadEnable() U0 PCNetTXAutoPadEnable()
{/* AMD PCNet datasheet p.1-958 {/* AMD PCNet datasheet p.1-958
Setting bit 11 (Auto Pad Transmit) allows Setting bit 11 (Auto Pad Transmit) allows
shoft transmit frames to be automatically short transmit frames to be automatically
extended to 64 bytes. */ extended to 64 bytes. */
U32 csr = PCNetCSRRead(PCNET_CSR_FEATURECTRL); U32 csr = PCNetCSRRead(PCNET_CSR_FEATURECTRL);
@ -465,6 +466,19 @@ U0 PCNetTXAutoPadEnable()
PCNetCSRWrite(PCNET_CSR_FEATURECTRL, csr); PCNetCSRWrite(PCNET_CSR_FEATURECTRL, csr);
} }
U0 PCNetRXAutoStripEnable()
{/* AMD PCNet datasheet p.1-958
Setting bit 10 (Auto Strip Receive) allows
pad and FCS fields to be automatically
stripped. ONLY WORKS ON 802.3!!! */
U32 csr = PCNetCSRRead(PCNET_CSR_FEATURECTRL);
Bts(&csr, PCNET_FEATURE_ASTRPRCV);
PCNetCSRWrite(PCNET_CSR_FEATURECTRL, csr);
}
U0 PCNetConfigModeExit() U0 PCNetConfigModeExit()
{/* AMD PCNet datasheet p.1-954 {/* AMD PCNet datasheet p.1-954
PCNet controller can be started PCNet controller can be started
@ -621,7 +635,13 @@ I64 PCNetPacketReceive(U8 **packet_buffer_out, U16 *packet_length_out)
NetDebug("PCNET RECEIVE PACKET: de_index incremented = 0x%0X", pcnet.current_rx_de_index); NetDebug("PCNET RECEIVE PACKET: de_index incremented = 0x%0X", pcnet.current_rx_de_index);
*packet_buffer_out = pcnet.rx_buffer_addr_phys + de_index * ETHERNET_FRAME_SIZE; *packet_buffer_out = pcnet.rx_buffer_addr_phys + de_index * ETHERNET_FRAME_SIZE;
*packet_length_out = packet_length;
// ASTRPRCV causes 802.3 packets to be stripped and FCS to be checked
U16 ethertype = (*packet_buffer_out)[ETHERNET_ETHERTYPE_OFFSET + 1] | (*packet_buffer_out)[ETHERNET_ETHERTYPE_OFFSET] << 8;
if (ethertype < ETHERNET_v2_MTU)
*packet_length_out = ethertype;
else
*packet_length_out = packet_length - FCS_LENGTH; // ethertype ii TODO: Validate FCS
return de_index; return de_index;
} }
@ -749,6 +769,8 @@ U0 PCNetInit()
PCNetTXAutoPadEnable; PCNetTXAutoPadEnable;
PCNetRXAutoStripEnable;
PCNetAutoLinkSelect; PCNetAutoLinkSelect;
PCNetEnableFullDuplex; PCNetEnableFullDuplex;

View File

@ -27,17 +27,15 @@ U0 EthernetGlobalsInit()
} }
} }
//TODO: check length , figure out the length+4
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length) U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
{ {
//TODO: Check length ! We need to figure out what // length is assumed to NOT include the FCS.
//lengths are appropriate
//Shrine also says MemCopy has a // Shrine says MemCopy has a high overhead.
//high overhead. Almost tempted to say that means that a lot // Almost tempted to say that means that a lot
//of the current system should be done with less extra allocation // of the current system should be done with
//altogether, more passing. // less extra allocation altogether, more passing.
//In practice, MemCopy causes the most slowdown on bare-metal. // In practice, MemCopy causes the most slowdown on bare-metal.
NetLog("ETHERNET FRAME PARSE: Parsing frame, copying out to frame_out param."); NetLog("ETHERNET FRAME PARSE: Parsing frame, copying out to frame_out param.");
@ -49,7 +47,7 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
frame_out->data = frame + ETHERNET_DATA_OFFSET; frame_out->data = frame + ETHERNET_DATA_OFFSET;
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - 4; // He has a comment literally just saying "??". + or - 4? frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH;
} }
U0 EthernetFrameFinish(I64 de_index) U0 EthernetFrameFinish(I64 de_index)

View File

@ -5,11 +5,14 @@
#define ETHERNET_ETHERTYPE_OFFSET 12 #define ETHERNET_ETHERTYPE_OFFSET 12
#define ETHERNET_DATA_OFFSET 14 #define ETHERNET_DATA_OFFSET 14
#define MAC_ADDRESS_LENGTH 6 #define MAC_ADDRESS_LENGTH 6
#define FCS_LENGTH 4
/* Ethernet Frame Size. /* Ethernet Frame Size.
Linux uses 1544, OSDev and Shrine use 1548. Based on IEEE 802.3as, max frame size was agreed upon as 2000 bytes. */ Linux uses 1544, OSDev and Shrine use 1548. Based on IEEE 802.3as, max frame size was agreed upon as 2000 bytes. */
#define ETHERNET_FRAME_SIZE 2000 #define ETHERNET_FRAME_SIZE 2000
#define ETHERNET_v2_MTU 1500
#define HTYPE_ETHERNET 1 #define HTYPE_ETHERNET 1
#define HLEN_ETHERNET 6 #define HLEN_ETHERNET 6
#define PLEN_IPV4 4 #define PLEN_IPV4 4

View File

@ -37,6 +37,16 @@ U0 NetQueueEntryHandle(CNetQueueEntry *entry)
EthernetFrameParse(&ethernet_frame, entry->frame, entry->packet_length); EthernetFrameParse(&ethernet_frame, entry->frame, entry->packet_length);
U8 *mac = EthernetMACGet();
Bool is_our_mac = !MemCompare(mac, ethernet_frame.destination_address, MAC_ADDRESS_LENGTH); // check the RX packet MAC against local MAC
Bool is_broadcast = !MemCompare(ethernet_globals.ethernet_broadcast, ethernet_frame.destination_address, MAC_ADDRESS_LENGTH); // check the RX packet MAC against broadcast MAC
if (!is_our_mac && !is_broadcast)
{
NetLog("HANDLE NETQUEUE ENTRY: Not for us, discarding.");
return;
}
switch (ethernet_frame.ethertype) switch (ethernet_frame.ethertype)
{ {
case ETHERTYPE_ARP: case ETHERTYPE_ARP:

View File

@ -110,6 +110,16 @@ Bool MyPutKey(I64 ch, I64 sc)
} }
return TRUE; return TRUE;
case SC_F12:
if (!(sc & SCF_SHIFT))
{
if (sc & SCF_KEY_DESC)
KeyDescSet("Cmd /SysLogToggle");
else
SysLogToggle;
}
return TRUE;
case SC_DELETE: case SC_DELETE:
if (sc & SCF_SHIFT) if (sc & SCF_SHIFT)
{ {

View File

@ -286,6 +286,7 @@ I64 AHCIAtapiCapacityGet(CBlkDev *bd)
cmd_fis->type = FISt_H2D; cmd_fis->type = FISt_H2D;
PCIBts(&cmd_fis->desc, AHCI_CF_DESCf_C); //Set Command bit in H2D FIS. PCIBts(&cmd_fis->desc, AHCI_CF_DESCf_C); //Set Command bit in H2D FIS.
cmd_fis->command = ATA_PACKET; cmd_fis->command = ATA_PACKET;
cmd_fis->lba1 = 8;
cmd_table->acmd[0] = ATAPI_READ_CAPACITY >> 8; cmd_table->acmd[0] = ATAPI_READ_CAPACITY >> 8;
AHCIPortWait(bd->port_num, tS + 2); AHCIPortWait(bd->port_num, tS + 2);

View File

@ -35,9 +35,9 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
} }
if (ch == '\t') if (ch == '\t')
{ {
do
RawPutChar(CH_SPACE); RawPutChar(CH_SPACE);
while (text.raw_col & 3) while (text.raw_col & 3);
RawPutChar(CH_SPACE);
} }
else if (ch == CH_BACKSPACE) else if (ch == CH_BACKSPACE)
{ {
@ -47,9 +47,9 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
} }
else if (ch == '\n') else if (ch == '\n')
{ {
do
RawPutChar(CH_SPACE); RawPutChar(CH_SPACE);
while (text.raw_col % text.cols) while (text.raw_col % text.cols);
RawPutChar(CH_SPACE);
} }
else if (Bt(char_bmp_displayable, ch)) else if (Bt(char_bmp_displayable, ch))
{ {
@ -60,17 +60,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
{//Scroll screen down {//Scroll screen down
MemCopy(text.fb_alias, MemCopy(text.fb_alias,
text.fb_alias + sys_framebuffer_width * FONT_HEIGHT, text.fb_alias + sys_framebuffer_pidth * FONT_HEIGHT,
(text.screen_size - sys_framebuffer_width * FONT_HEIGHT) * sizeof(U32)); (text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT) * sizeof(U32));
MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_width * FONT_HEIGHT, BLACK32, sys_framebuffer_width * FONT_HEIGHT); MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT, BLACK32, sys_framebuffer_pidth * FONT_HEIGHT);
text.raw_col -= text.cols ; text.raw_col -= text.cols ;
row = text.rows - 1; row = text.rows - 1;
} }
x = col * FONT_WIDTH; x = col * FONT_WIDTH;
y = row * FONT_HEIGHT; y = row * FONT_HEIGHT;
ch_bitmap = text.font[ch & 0xFF]; ch_bitmap = text.font[ch & 0xFF];
framebuffer = text.fb_alias + sys_framebuffer_width * y + x; framebuffer = text.fb_alias + sys_framebuffer_pidth * y + x;
PUSHFD PUSHFD
CLI CLI
@ -81,7 +81,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
else else
*framebuffer++ = BLACK32; *framebuffer++ = BLACK32;
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1) if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
framebuffer += sys_framebuffer_width - FONT_WIDTH; framebuffer += sys_framebuffer_pidth - FONT_WIDTH;
ch_bitmap >>= 1; ch_bitmap >>= 1;
} }
POPFD POPFD

View File

@ -504,6 +504,14 @@ I64 Sys(U8 *format, ...)
return res; return res;
} }
U0 SysLogToggle()
{
if (Bt(&sys_task->display_flags, DISPLAYf_SHOW))
LBtr(&sys_task->display_flags, DISPLAYf_SHOW);
else
LBts(&sys_task->display_flags, DISPLAYf_SHOW);
}
U0 SysLog(U8 *format, ...) U0 SysLog(U8 *format, ...)
{//Display text in sys_task. {//Display text in sys_task.
U8 *buf = StrPrintJoin(NULL, format, argc, argv); U8 *buf = StrPrintJoin(NULL, format, argc, argv);

View File

@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
CDate local_time_offset; CDate local_time_offset;
F64 *pow10_I64, F64 *pow10_I64,
sys_os_version = 2.03; sys_os_version = 2.03;
U64 sys_os_version_sub = 108; U64 sys_os_version_sub = 120;
U8 *sys_os_version_str; U8 *sys_os_version_str;
U8 *sys_os_version_full; U8 *sys_os_version_full;
U8 *sys_os_version_nice; U8 *sys_os_version_nice;

View File

@ -91,7 +91,8 @@ U0 SysGrInit()
text.cols = sys_framebuffer_width / FONT_WIDTH; text.cols = sys_framebuffer_width / FONT_WIDTH;
text.rows = sys_framebuffer_height / FONT_HEIGHT; text.rows = sys_framebuffer_height / FONT_HEIGHT;
text.screen_size = sys_framebuffer_width * sys_framebuffer_height; sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);
text.screen_size = sys_framebuffer_pidth * sys_framebuffer_height;
text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now. text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now.
text.raw_screen = CAlloc(text.buffer_size); text.raw_screen = CAlloc(text.buffer_size);
text.fb_alias = sys_framebuffer_addr; text.fb_alias = sys_framebuffer_addr;

View File

@ -1272,7 +1272,7 @@ public class CDocBin
#assert !($$ & 7) #assert !($$ & 7)
}; };
#define DOC_SCROLL_SPEED 8 #define DOC_SCROLL_SPEED 6
#define DOCSS_NORMAL 0 #define DOCSS_NORMAL 0
#define DOCSS_SINGLE_QUOTE 1 #define DOCSS_SINGLE_QUOTE 1
@ -3026,7 +3026,7 @@ class CAtapiModeWriteList
#define FILEMASK_AOT "*.ZC*;*.HH*;*.PRJ*" #define FILEMASK_AOT "*.ZC*;*.HH*;*.PRJ*"
#define FILEMASK_SRC "*.ZC*;*.HH*;*.IN*;*.PRJ*" #define FILEMASK_SRC "*.ZC*;*.HH*;*.IN*;*.PRJ*"
#define FILEMASK_DD FILEMASK_SRC ";*.DD*" #define FILEMASK_DD FILEMASK_SRC ";*.DD*"
#define FILEMASK_TXT FILEMASK_DD ";*.TXT*;*.CFG*" #define FILEMASK_TXT FILEMASK_DD ";*.TXT*;*.CFG*;*.CONF*"
#define FILEMASK_GR "*.GR*" #define FILEMASK_GR "*.GR*"
#help_index "File/Low Level" #help_index "File/Low Level"

View File

@ -249,7 +249,7 @@ public _extern SYS_FRAMEBUFFER_WIDTH U64 sys_framebuffer_width;
public _extern SYS_FRAMEBUFFER_HEIGHT U64 sys_framebuffer_height; public _extern SYS_FRAMEBUFFER_HEIGHT U64 sys_framebuffer_height;
public _extern SYS_FRAMEBUFFER_PITCH U64 sys_framebuffer_pitch; public _extern SYS_FRAMEBUFFER_PITCH U64 sys_framebuffer_pitch;
public _extern SYS_FRAMEBUFFER_BPP U8 sys_framebuffer_bpp; public _extern SYS_FRAMEBUFFER_BPP U8 sys_framebuffer_bpp;
public U64 sys_framebuffer_pidth;
_extern SYS_FRAMEBUFFER_LIST CVideoInfo sys_framebuffer_list[VBE_MODES_NUM]; _extern SYS_FRAMEBUFFER_LIST CVideoInfo sys_framebuffer_list[VBE_MODES_NUM];
#help_index "Processor/SMBIOS" #help_index "Processor/SMBIOS"

View File

@ -437,6 +437,7 @@ public extern I64 Scale2Mem(I64 min, I64 max, I64 limit=2*1024*1024*1024);
public extern U0 SysErr( U8 *format, ...); public extern U0 SysErr( U8 *format, ...);
public extern U0 SysWarn(U8 *format, ...); public extern U0 SysWarn(U8 *format, ...);
public extern U0 SysLog( U8 *format, ...); public extern U0 SysLog( U8 *format, ...);
public extern U0 SysLogToggle();
public extern I64 ExeCmdLine(CCompCtrl *cc); public extern I64 ExeCmdLine(CCompCtrl *cc);
public extern U0 JobDel(CJob *tmpc); public extern U0 JobDel(CJob *tmpc);
public extern I64 JobsHandler(I64 run_flags, CTask *task=NULL); public extern I64 JobsHandler(I64 run_flags, CTask *task=NULL);

View File

@ -242,7 +242,7 @@ and take address.
*/ */
U8 *buf, *ptr, **pptr; U8 *buf, *ptr, **pptr;
Bool left_justify = FALSE; Bool left_justify = FALSE;
I64 ch, cur_arg = 0, i, len, *i_ptr, dec_len; I64 ch, cur_arg = 0, len, *i_ptr, dec_len;
F64 *d_ptr; F64 *d_ptr;
if (!format) if (!format)
@ -301,9 +301,9 @@ and take address.
} }
} }
buf = MAlloc(len + 1); buf = MAlloc(len + 1);
for (i = 0; i < len; i++) MemCopy(buf, src, len);
buf[i] = *src++; buf[len] = 0;
buf[i] = 0; src += len;
switch (ch) switch (ch)
{ {
case 's': case 's':

View File

@ -111,7 +111,7 @@ U0 OSMerge(U8 dst_drv, U8 src_drv=':')
Del("B:/Misc/Bible.TXT"); // Deleting from B:/ prevents causing hang when merging large .TXT files, Del("B:/Misc/Bible.TXT"); // Deleting from B:/ prevents causing hang when merging large .TXT files,
Del("B:/Misc/Clementine.TXT"); // they will instead be copied over from boot drive in OSMergeInner Del("B:/Misc/Clementine.TXT"); // they will instead be copied over from boot drive in OSMergeInner
Del("B:/Boot/Limine.CFG"); // Delete to make merge output ignore (copy) this, since it gets regenerated later Del("B:/Boot/Limine.CONF"); // Delete to make merge output ignore (copy) this, since it gets regenerated later
DocMax; DocMax;
@ -129,7 +129,7 @@ U0 OSMerge(U8 dst_drv, U8 src_drv=':')
ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", dst_drv);
ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", dst_drv);
ExePrint("Del(\"%C:/Boot/Limine.CFG\");", dst_drv); ExePrint("Del(\"%C:/Boot/Limine.CONF\");", dst_drv);
ExePrint("Del(\"%C:/boot.catalog\");", dst_drv); ExePrint("Del(\"%C:/boot.catalog\");", dst_drv);
} }
@ -208,7 +208,7 @@ U0 OSUpgrade()
if (ch == 'Z') if (ch == 'Z')
{ {
BootMHDIns(drv_let); BootMHDIns(drv_let);
"\n(Generating optional UEFI-mode Limine.CFG...)\n"; "\n(Generating optional UEFI-mode Limine.CONF...)\n";
LimineCFGMake(drv_let); LimineCFGMake(drv_let);
} }
else else
@ -247,7 +247,7 @@ U0 InstallDrive(U8 drv_let)
ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine-BIOS-CD.BIN\");", drv_let);
ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine-UEFI-CD.BIN\");", drv_let);
ExePrint("Del(\"%C:/Boot/Limine.CFG\");", drv_let); ExePrint("Del(\"%C:/Boot/Limine.CONF\");", drv_let);
ExePrint("Del(\"%C:/boot.catalog\");", drv_let); ExePrint("Del(\"%C:/boot.catalog\");", drv_let);
ExePrint("DirMake(\"%C:/Tmp\");", drv_let); ExePrint("DirMake(\"%C:/Tmp\");", drv_let);
@ -351,7 +351,7 @@ U0 VMInstallWiz()
if (ch == 'Z') if (ch == 'Z')
{ {
BootMHDIns('C'); BootMHDIns('C');
"\n(Generating optional UEFI-mode Limine.CFG...)\n"; "\n(Generating optional UEFI-mode Limine.CONF...)\n";
LimineCFGMake('C'); LimineCFGMake('C');
} }
else else
@ -467,8 +467,8 @@ U0 RegularInstallWiz()
if (ch == 'Z') if (ch == 'Z')
{ {
BootMHDIns(drv_let); BootMHDIns(drv_let);
"\n(Generating optional UEFI-mode Limine.CFG...)\n"; "\n(Generating optional UEFI-mode Limine.CONF...)\n";
LimineCFGMake(drv_let); // ensures we don't leave the LiveCD's Limine.CFG on the HDD LimineCFGMake(drv_let); // ensures we don't leave the LiveCD's Limine.CONF on the HDD
} }
else else
{ {

View File

@ -13,18 +13,18 @@ U8 binary_limine_hdd_bin_data[0];
Bool LimineCFGMake(U8 drv_let) Bool LimineCFGMake(U8 drv_let)
{ {
U8 *filename_cfg = MStrPrint("%C:/Boot/Limine.CFG", drv_let); U8 *filename_cfg = MStrPrint("%C:/Boot/Limine.CONF", drv_let);
CDoc *doc = DocNew(filename_cfg); CDoc *doc = DocNew(filename_cfg);
CDrive *drive; CDrive *drive;
CBlkDev *bd; CBlkDev *bd;
I64 i; I64 i;
U8 *filename_sys, *filename_elf, *filename_zxe, *st; U8 *filename_sys, *filename_elf, *filename_zxe, *st;
"\nGenerating Limine.CFG ...\n"; "\nGenerating Limine.CONF ...\n";
DocPrint(doc, DocPrint(doc,
"TIMEOUT=2\n" "timeout: 2\n"
"INTERFACE_RESOLUTION=1024x768\n\n"); "interface_resolution: 1024x768\n\n");
"Searching drives for Limine bootloader files ...\n"; "Searching drives for Limine bootloader files ...\n";
for (i = 0, drive = blkdev.drvs; i < DRIVES_NUM; i++, drive++) for (i = 0, drive = blkdev.drvs; i < DRIVES_NUM; i++, drive++)
@ -39,15 +39,15 @@ Bool LimineCFGMake(U8 drv_let)
filename_zxe = MStrPrint("%C:/Boot/Kernel.ZXE", drv_let); filename_zxe = MStrPrint("%C:/Boot/Kernel.ZXE", drv_let);
if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe)) if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe))
{ {
st = MStrPrint(":ZealOS %C:/\n" st = MStrPrint("/ZealOS %C:/\n"
"PROTOCOL=limine\n" "protocol: limine\n"
"RESOLUTION=1024x768\n" "resolution: 1024x768\n"
"KERNEL_PATH=boot://%d/Boot/ZealBooter.ELF\n" "kernel_path: boot(%d):/Boot/ZealBooter.ELF\n"
"MODULE_PATH=boot://%d/Boot/Kernel.ZXE\n" "module_path: boot(%d):/Boot/Kernel.ZXE\n"
"\n", drv_let, drive->prt_num + 1, drive->prt_num + 1); "\n", drv_let, drive->prt_num + 1, drive->prt_num + 1);
DocPrint(doc, st); DocPrint(doc, st);
"%C:/ drive added as a Limine.CFG menu entry.\n", drv_let; "%C:/ drive added as a Limine.CONF menu entry.\n", drv_let;
} }
else else
"%C:/ drive is missing Limine bootloader files.\n", drv_let; "%C:/ drive is missing Limine bootloader files.\n", drv_let;
@ -56,9 +56,9 @@ Bool LimineCFGMake(U8 drv_let)
DocWrite(doc); DocWrite(doc);
DocDel(doc); DocDel(doc);
"/Boot/Limine.CFG generated.\n"; "/Boot/Limine.CONF generated.\n";
"Copying Limine.CFG to all other drives ...\n"; "Copying Limine.CONF to all other drives ...\n";
for (i = 0, drive = blkdev.drvs; i < DRIVES_NUM; i++, drive++) for (i = 0, drive = blkdev.drvs; i < DRIVES_NUM; i++, drive++)
{ {
if (drive->drive_signature == DRIVE_SIGNATURE_VAL && drive->fs_type == FSt_FAT32 && DriveIsWritable(drive->drv_let)) if (drive->drive_signature == DRIVE_SIGNATURE_VAL && drive->fs_type == FSt_FAT32 && DriveIsWritable(drive->drv_let))
@ -66,7 +66,7 @@ Bool LimineCFGMake(U8 drv_let)
drv_let = Drive2Letter(drive); drv_let = Drive2Letter(drive);
if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe)) if (FileFind(filename_sys) && FileFind(filename_elf) && FileFind(filename_zxe))
{ {
st = MStrPrint("%C:/Boot/Limine.CFG", drv_let); st = MStrPrint("%C:/Boot/Limine.CONF", drv_let);
Copy(filename_cfg, st); Copy(filename_cfg, st);
} }
} }

View File

@ -137,11 +137,11 @@ public U0 DocClear(CDoc *doc=NULL, Bool clear_holds=FALSE)
{//Clear all doc entries, except +H, hold entries. {//Clear all doc entries, except +H, hold entries.
Bool unlock; Bool unlock;
text.raw_col = 0;
if (!doc && !(doc = DocPut)) if (!doc && !(doc = DocPut))
{ {
if (IsRaw) if (IsRaw)
{ {
text.raw_col = 0;
MemSet(text.fb_alias, BLACK32, text.buffer_size); MemSet(text.fb_alias, BLACK32, text.buffer_size);
} }
return; return;

View File

@ -214,7 +214,8 @@ public CDC *DCNew(I64 width, I64 height, CTask *task=NULL, Bool null_bitmap=FALS
res->win_task = task; res->win_task = task;
res->mem_task = task; res->mem_task = task;
res->width = width; res->width = width;
res->width_internal = (width + 7) & ~7; // res->width_internal = (width + 7) & ~7;
res->width_internal = width & ~7;
res->height = height; res->height = height;
if (null_bitmap) if (null_bitmap)
res->flags |= DCF_DONT_DRAW; res->flags |= DCF_DONT_DRAW;

View File

@ -47,7 +47,7 @@ public CBGR24 gr_palette[COLORS_NUM];
//See $LK,"SysGrInit",A="MN:SysGrInit"$() //See $LK,"SysGrInit",A="MN:SysGrInit"$()
//Allows consts to be used instead of variables. //Allows consts to be used instead of variables.
HashPublic("GR_WIDTH", HTT_DEFINE_STR);; HashPublic("GR_WIDTH", HTT_DEFINE_STR);;
DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width); DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width & ~7);
HashPublic("GR_HEIGHT", HTT_DEFINE_STR);; HashPublic("GR_HEIGHT", HTT_DEFINE_STR);;
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height); DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);
@ -56,3 +56,5 @@ DefinePrint("TEXT_ROWS", "%d", text.rows);;
HashPublic("TEXT_ROWS", HTT_DEFINE_STR);; HashPublic("TEXT_ROWS", HTT_DEFINE_STR);;
DefinePrint("TEXT_COLS", "%d", text.cols);; DefinePrint("TEXT_COLS", "%d", text.cols);;
HashPublic("TEXT_COLS", HTT_DEFINE_STR);; HashPublic("TEXT_COLS", HTT_DEFINE_STR);;
sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);

View File

@ -142,8 +142,8 @@ public U0 GrScaleZoom(F64 scale)
mouse.offset.x = mouse.pos.x - (mouse.pos.x - mouse.offset.x) * s; mouse.offset.x = mouse.pos.x - (mouse.pos.x - mouse.offset.x) * s;
mouse.offset.y = mouse.pos.y - (mouse.pos.y - mouse.offset.y) * s; mouse.offset.y = mouse.pos.y - (mouse.pos.y - mouse.offset.y) * s;
mouse.offset.z = mouse.pos.z - (mouse.pos.z - mouse.offset.z) * s; mouse.offset.z = mouse.pos.z - (mouse.pos.z - mouse.offset.z) * s;
gr.sx = mouse.pos.x - gr.zoomed_dc->width >> 1 / gr.screen_zoom; gr.sx = mouse.pos.x - GR_WIDTH >> 1 / gr.screen_zoom;
gr.sy = mouse.pos.y - gr.zoomed_dc->height >> 1 / gr.screen_zoom; gr.sy = mouse.pos.y - GR_HEIGHT >> 1 / gr.screen_zoom;
GrFixZoomScale; GrFixZoomScale;
} }
@ -154,7 +154,7 @@ U0 GrZoomInScreen()
GrFixZoomScale; GrFixZoomScale;
src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal; src = gr.dc2->body + gr.sx + gr.sy * GR_WIDTH;
dst = gr.zoomed_dc->body; dst = gr.zoomed_dc->body;
for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++) for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++)
@ -359,42 +359,53 @@ U0 DCBlotColor8(CDC *dc, CDC *img)
U0 GrCalcScreenUpdates() U0 GrCalcScreenUpdates()
{ {
U16 *screen, *last_screen = gr.screen_cache; U8 *screen, reg RCX *last_screen = gr.screen_cache;
U64 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT / 2; U32 *src = text.raw_screen, *dst = text.fb_alias;
U64 i, j, x, y, yi;
if (gr.screen_zoom == 1) if (gr.screen_zoom == 1)
screen = gr.dc2->body; screen = gr.dc2->body;
else else
screen = gr.zoomed_dc->body; screen = gr.zoomed_dc->body;
for (i = 0; i < diffs_size; i++) for (y = yi = 0; y < GR_HEIGHT; yi = ++y * GR_WIDTH)
{ {
for (x = 0; x < GR_WIDTH; x++)
{
i = x + yi;
j = x + y * sys_framebuffer_pidth;
if (screen[i] != last_screen[i]) if (screen[i] != last_screen[i])
dst[i] = src[i]; {
dst = text.fb_alias + j;
src = text.raw_screen + j;
*dst = *src;
} }
MemCopy(gr.screen_cache, screen, diffs_size * 2); }
}
MemCopy(gr.screen_cache, screen, GR_WIDTH * GR_HEIGHT);
} }
U0 GrUpdateScreen32() U0 GrUpdateScreen32()
{ {
U64 size, *dst; U64 x, y, j, i;
U32 *dst;
U8 *src; U8 *src;
if (gr.screen_zoom == 1) if (gr.screen_zoom == 1)
{
src = gr.dc2->body; src = gr.dc2->body;
size = src + gr.dc2->height * gr.dc2->width_internal;
}
else else
{ {
GrZoomInScreen; GrZoomInScreen;
src = gr.zoomed_dc->body; src = gr.zoomed_dc->body;
size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal;
} }
dst = text.raw_screen; for (y = j = i = 0; y < GR_HEIGHT; j = ++y * sys_framebuffer_pidth, i = y * GR_WIDTH)
while (src < size) //draw 2 pixels at a time {
*dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32; for (x = 0; x < GR_WIDTH; x++)
{
dst = text.raw_screen + x + j;
*dst = gr_palette[src[x + i] & 0xFF];
}
}
GrCalcScreenUpdates; GrCalcScreenUpdates;
@ -420,6 +431,6 @@ U0 GrUpdateScreen()
(*gr.fp_final_screen_update)(dc); (*gr.fp_final_screen_update)(dc);
DCDel(dc); DCDel(dc);
DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, gr.dc2->height * gr.dc2->width_internal >> 3); DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, GR_HEIGHT * GR_WIDTH >> 3);
GrUpdateScreen32; GrUpdateScreen32;
} }

View File

@ -1,48 +1,43 @@
# Nuke built-in rules and variables. # Nuke built-in rules and variables.
override MAKEFLAGS += -rR MAKEFLAGS += -rR
.SUFFIXES:
# This is the name that our final kernel executable will have. # This is the name that our final executable will have.
# Change as needed. # Change as needed.
override KERNEL := kernel override OUTPUT := kernel
# Convenience macro to reliably declare user overridable variables. # Convenience macro to reliably declare user overridable variables.
define DEFAULT_VAR = override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2)))
ifeq ($(origin $1),default)
override $(1) := $(2)
endif
ifeq ($(origin $1),undefined)
override $(1) := $(2)
endif
endef
# It is suggested to use a custom built cross toolchain to build a kernel. # User controllable C compiler command.
# We are using the standard "cc" here, it may work by using $(call USER_VARIABLE,KCC,cc)
# the host system's toolchain, but this is not guaranteed.
override DEFAULT_CC := cc
$(eval $(call DEFAULT_VAR,CC,$(DEFAULT_CC)))
# Same thing for "ld" (the linker). # User controllable linker command.
override DEFAULT_LD := ld $(call USER_VARIABLE,KLD,ld)
$(eval $(call DEFAULT_VAR,LD,$(DEFAULT_LD)))
# User controllable C flags. # User controllable C flags.
override DEFAULT_CFLAGS := -g -O2 -pipe $(call USER_VARIABLE,KCFLAGS,-g -O2 -pipe)
$(eval $(call DEFAULT_VAR,CFLAGS,$(DEFAULT_CFLAGS)))
# User controllable C preprocessor flags. We set none by default. # User controllable C preprocessor flags. We set none by default.
override DEFAULT_CPPFLAGS := $(call USER_VARIABLE,KCPPFLAGS,)
$(eval $(call DEFAULT_VAR,CPPFLAGS,$(DEFAULT_CPPFLAGS)))
# User controllable nasm flags. # User controllable nasm flags.
override DEFAULT_NASMFLAGS := -F dwarf -g $(call USER_VARIABLE,KNASMFLAGS,-F dwarf -g)
$(eval $(call DEFAULT_VAR,NASMFLAGS,$(DEFAULT_NASMFLAGS)))
# User controllable linker flags. We set none by default. # User controllable linker flags. We set none by default.
override DEFAULT_LDFLAGS := $(call USER_VARIABLE,KLDFLAGS,)
$(eval $(call DEFAULT_VAR,LDFLAGS,$(DEFAULT_LDFLAGS)))
# Check if KCC is Clang.
override KCC_IS_CLANG := $(shell ! $(KCC) --version 2>/dev/null | grep 'clang' >/dev/null 2>&1; echo $$?)
# If the C compiler is Clang, set the target as needed.
ifeq ($(KCC_IS_CLANG),1)
override KCC += \
-target x86_64-unknown-none
endif
# Internal C flags that should not be changed by the user. # Internal C flags that should not be changed by the user.
override CFLAGS += \ override KCFLAGS += \
-Wall \ -Wall \
-Wextra \ -Wextra \
-std=gnu11 \ -std=gnu11 \
@ -50,8 +45,9 @@ override CFLAGS += \
-fno-stack-protector \ -fno-stack-protector \
-fno-stack-check \ -fno-stack-check \
-fno-lto \ -fno-lto \
-fno-PIE \
-fno-PIC \ -fno-PIC \
-ffunction-sections \
-fdata-sections \
-m64 \ -m64 \
-march=x86-64 \ -march=x86-64 \
-mno-80387 \ -mno-80387 \
@ -62,50 +58,46 @@ override CFLAGS += \
-mcmodel=kernel -mcmodel=kernel
# Internal C preprocessor flags that should not be changed by the user. # Internal C preprocessor flags that should not be changed by the user.
override CPPFLAGS := \ override KCPPFLAGS := \
-I src \ -I src \
-I src/lib \ -I src/lib \
$(CPPFLAGS) \ $(KCPPFLAGS) \
-MMD \ -MMD \
-MP -MP
# Internal nasm flags that should not be changed by the user.
override KNASMFLAGS += \
-Wall \
-f elf64
# Internal linker flags that should not be changed by the user. # Internal linker flags that should not be changed by the user.
override LDFLAGS += \ override KLDFLAGS += \
-m elf_x86_64 \ -m elf_x86_64 \
-nostdlib \ -nostdlib \
-static \ -static \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-gc-sections \
-T linker.ld -T linker.ld
# Check if the linker supports -no-pie and enable it if it does.
ifeq ($(shell $(LD) --help 2>&1 | grep 'no-pie' >/dev/null 2>&1; echo $$?),0)
override LDFLAGS += -no-pie
endif
# Internal nasm flags that should not be changed by the user.
override NASMFLAGS += \
-Wall \
-f elf64
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the # Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
# object and header dependency file names. # object and header dependency file names.
override CFILES := $(shell cd src && find -L . -type f -name '*.c') override CFILES := $(shell cd src && find -L * -type f -name '*.c' | LC_ALL=C sort)
override ASFILES := $(shell cd src && find -L . -type f -name '*.S') override ASFILES := $(shell cd src && find -L * -type f -name '*.S' | LC_ALL=C sort)
override NASMFILES := $(shell cd src && find -L . -type f -name '*.asm') override NASMFILES := $(shell cd src && find -L * -type f -name '*.asm' | LC_ALL=C sort)
override OBJ := $(addprefix obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o)) override OBJ := $(addprefix obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o))
override HEADER_DEPS := $(addprefix obj/,$(CFILES:.c=.c.d) $(ASFILES:.S=.S.d)) override HEADER_DEPS := $(addprefix obj/,$(CFILES:.c=.c.d) $(ASFILES:.S=.S.d))
# Default target. # Default target.
.PHONY: all .PHONY: all
all: bin/$(KERNEL) all: bin/$(OUTPUT)
src/limine.h: src/limine.h:
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h src/limine.h || echo "ERROR" curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h || cp ../build/limine/limine.h src/limine.h || echo "ERROR"
# Link rules for the final kernel executable. # Link rules for the final executable.
bin/$(KERNEL): GNUmakefile linker.ld $(OBJ) bin/$(OUTPUT): GNUmakefile linker.ld $(OBJ)
mkdir -p "$$(dirname $@)" mkdir -p "$$(dirname $@)"
$(LD) $(OBJ) $(LDFLAGS) -o $@ $(KLD) $(OBJ) $(KLDFLAGS) -o $@
# Include header dependencies. # Include header dependencies.
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
@ -113,17 +105,17 @@ bin/$(KERNEL): GNUmakefile linker.ld $(OBJ)
# Compilation rules for *.c files. # Compilation rules for *.c files.
obj/%.c.o: src/%.c GNUmakefile src/limine.h obj/%.c.o: src/%.c GNUmakefile src/limine.h
mkdir -p "$$(dirname $@)" mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@
# Compilation rules for *.S files. # Compilation rules for *.S files.
obj/%.S.o: src/%.S GNUmakefile src/limine.h obj/%.S.o: src/%.S GNUmakefile src/limine.h
mkdir -p "$$(dirname $@)" mkdir -p "$$(dirname $@)"
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(KCC) $(KCFLAGS) $(KCPPFLAGS) -c $< -o $@
# Compilation rules for *.asm (nasm) files. # Compilation rules for *.asm (nasm) files.
obj/%.asm.o: src/%.asm GNUmakefile obj/%.asm.o: src/%.asm GNUmakefile
mkdir -p "$$(dirname $@)" mkdir -p "$$(dirname $@)"
nasm $(NASMFLAGS) $< -o $@ nasm $(KNASMFLAGS) $< -o $@
# Remove object files and the final executable. # Remove object files and the final executable.
.PHONY: clean .PHONY: clean

View File

@ -1,8 +0,0 @@
TIMEOUT=2
INTERFACE_RESOLUTION=1024x768
:ZealOS LiveCD
PROTOCOL=limine
RESOLUTION=1024x768
KERNEL_PATH=boot:///Boot/ZealBooter.ELF
MODULE_PATH=boot:///Boot/Kernel.ZXE

8
zealbooter/limine.conf Normal file
View File

@ -0,0 +1,8 @@
timeout: 2
interface_resolution: 1024x768
/ZealOS LiveCD
protocol: limine
resolution: 1024x768
kernel_path: boot():/Boot/ZealBooter.ELF
module_path: boot():/Boot/Kernel.ZXE

View File

@ -1,40 +1,51 @@
/* Tell the linker that we want an x86_64 ELF64 output file */ /* Tell the linker that we want an x86_64 ELF64 output file */
OUTPUT_FORMAT(elf64-x86-64) OUTPUT_FORMAT(elf64-x86-64)
OUTPUT_ARCH(i386:x86-64)
/* We want the symbol _start to be our entry point */ /* We want the symbol kmain to be our entry point */
ENTRY(_start) ENTRY(kmain)
/* Define the program headers we want so the bootloader gives us the right */ /* Define the program headers we want so the bootloader gives us the right */
/* MMU permissions */ /* MMU permissions; this also allows us to exert more control over the linking */
/* process. */
PHDRS PHDRS
{ {
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */ requests PT_LOAD;
rodata PT_LOAD FLAGS((1 << 2)) ; /* Read only */ text PT_LOAD;
data PT_LOAD FLAGS((1 << 1) | (1 << 2)) ; /* Write + Read */ rodata PT_LOAD;
data PT_LOAD;
} }
SECTIONS SECTIONS
{ {
/* We wanna be placed in the topmost 2GiB of the address space, for optimisations */ /* We want to be placed in the topmost 2GiB of the address space, for optimisations */
/* and because that is what the Limine spec mandates. */ /* and because that is what the Limine spec mandates. */
/* Any address in this region will do, but often 0xffffffff80000000 is chosen as */ /* Any address in this region will do, but often 0xffffffff80000000 is chosen as */
/* that is the beginning of the region. */ /* that is the beginning of the region. */
. = 0xffffffff80000000; . = 0xffffffff80000000;
/* Define a section to contain the Limine requests and assign it to its own PHDR */
.requests : {
KEEP(*(.requests_start_marker))
KEEP(*(.requests))
KEEP(*(.requests_end_marker))
} :requests
/* Move to the next memory page for .text */
. = ALIGN(CONSTANT(MAXPAGESIZE));
.text : { .text : {
*(.text .text.*) *(.text .text.*)
} :text } :text
/* Move to the next memory page for .rodata */ /* Move to the next memory page for .rodata */
. += CONSTANT(MAXPAGESIZE); . = ALIGN(CONSTANT(MAXPAGESIZE));
.rodata : { .rodata : {
*(.rodata .rodata.*) *(.rodata .rodata.*)
} :rodata } :rodata
/* Move to the next memory page for .data */ /* Move to the next memory page for .data */
. += CONSTANT(MAXPAGESIZE); . = ALIGN(CONSTANT(MAXPAGESIZE));
.data : { .data : {
*(.data .data.*) *(.data .data.*)
@ -49,9 +60,9 @@ SECTIONS
*(COMMON) *(COMMON)
} :data } :data
/* Discard .note.* and .eh_frame since they may cause issues on some hosts. */ /* Discard .note.* and .eh_frame* since they may cause issues on some hosts. */
/DISCARD/ : { /DISCARD/ : {
*(.eh_frame) *(.eh_frame*)
*(.note .note.*) *(.note .note.*)
} }
} }

View File

@ -4,31 +4,43 @@
#include <limine.h> #include <limine.h>
#include <lib.h> #include <lib.h>
__attribute__((used, section(".requests_start_marker")))
static volatile LIMINE_REQUESTS_START_MARKER;
__attribute__((used, section(".requests_end_marker")))
static volatile LIMINE_REQUESTS_END_MARKER;
__attribute__((used, section(".requests")))
static volatile struct limine_module_request module_request = { static volatile struct limine_module_request module_request = {
.id = LIMINE_MODULE_REQUEST, .id = LIMINE_MODULE_REQUEST,
.revision = 0 .revision = 0
}; };
__attribute__((used, section(".requests")))
static volatile struct limine_hhdm_request hhdm_request = { static volatile struct limine_hhdm_request hhdm_request = {
.id = LIMINE_HHDM_REQUEST, .id = LIMINE_HHDM_REQUEST,
.revision = 0 .revision = 0
}; };
__attribute__((used, section(".requests")))
static volatile struct limine_memmap_request memmap_request = { static volatile struct limine_memmap_request memmap_request = {
.id = LIMINE_MEMMAP_REQUEST, .id = LIMINE_MEMMAP_REQUEST,
.revision = 0 .revision = 0
}; };
__attribute__((used, section(".requests")))
static volatile struct limine_framebuffer_request framebuffer_request = { static volatile struct limine_framebuffer_request framebuffer_request = {
.id = LIMINE_FRAMEBUFFER_REQUEST, .id = LIMINE_FRAMEBUFFER_REQUEST,
.revision = 0 .revision = 0
}; };
__attribute__((used, section(".requests")))
static volatile struct limine_smbios_request smbios_request = { static volatile struct limine_smbios_request smbios_request = {
.id = LIMINE_SMBIOS_REQUEST, .id = LIMINE_SMBIOS_REQUEST,
.revision = 0 .revision = 0
}; };
__attribute__((used, section(".requests")))
static volatile struct limine_efi_system_table_request efi_request = { static volatile struct limine_efi_system_table_request efi_request = {
.id = LIMINE_EFI_SYSTEM_TABLE_REQUEST, .id = LIMINE_EFI_SYSTEM_TABLE_REQUEST,
.revision = 0 .revision = 0
@ -167,7 +179,7 @@ static struct E801 get_E801(void) {
return E801; return E801;
} }
void _start(void) { void kmain(void) {
printf("ZealBooter prekernel\n"); printf("ZealBooter prekernel\n");
printf("____________________\n\n"); printf("____________________\n\n");