Skip to content

Commit

Permalink
Merge branch 'master' into strscan_memcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
GutPuncher committed Mar 7, 2024
2 parents 8e5f169 + 8662e5c commit 1b7f2bb
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 26 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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
if: ${{ success() }}
run: |
cd build
./build-iso.sh --headless
cd ..
- 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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.

Expand Down
Binary file modified build/AUTO.ISO
Binary file not shown.
18 changes: 11 additions & 7 deletions build/build-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ then
exit
fi

# Uncomment if you use doas instead of sudo
#alias sudo=doas
[ "$1" = "--headless" ] && QEMU_HEADLESS='-display none'

KVM=''
(lsmod | grep -q kvm) && KVM=' -accel kvm'

# Set this true if you want to test ISOs in QEMU after building.
TESTING=false
Expand Down Expand Up @@ -50,7 +52,7 @@ set +e

echo "Making temp vdisk, running auto-install ..."
$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/ ..."
rm ../src/Home/Registry.ZC 2> /dev/null
Expand All @@ -62,7 +64,7 @@ sudo cp -r ../src/* $TMPMOUNT/Tmp/OSBuild
umount_tempdisk

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"

Expand All @@ -73,6 +75,8 @@ then
git fetch
git remote set-head origin $LIMINE_BINARY_BRANCH
git switch $LIMINE_BINARY_BRANCH
git config --local pull.ff true
git config --local pull.rebase true
git pull
rm limine

Expand Down Expand Up @@ -130,11 +134,11 @@ if [ "$TESTING" = true ]; then
cd ..
fi
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 ..."
$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 ..."
$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

# comment these 2 lines if you want lingering old Distro ISOs
Expand Down
2 changes: 1 addition & 1 deletion build/git-pr-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ read -p "Enter fork branch name: " FORK_BRANCH
echo $FORK_BRANCH
FORK_LOCAL=$FORK_BRANCH"-testing"
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..."
git pull https://github.com/$FORK_USERNAME/ZealOS.git $FORK_BRANCH

Expand Down
1 change: 1 addition & 0 deletions build/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ else
umount_vdisk
[ -f ../src/Tmp/AUTO.ISO.C ] && mv ../src/Tmp/AUTO.ISO.C ./AUTO.ISO
echo "Finished."
cd ../
git status
;;
vm)
Expand Down
15 changes: 11 additions & 4 deletions src/Demo/Games/Chess.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ Bool MoveDo(GameState *state, I64 piece_num, I64 x2, I64 y2, Bool final)
game_over = TRUE;
}
GameSnapShot;
}
}

return ToBool(score_adjust);
return ToBool(score_adjust);
}

I64 MoveFind(I64 x, I64 y, Move *mvs, I64 mv_cnt)
Expand Down Expand Up @@ -664,18 +664,25 @@ I64 MoveCnt(GameState *state)
{
I64 i, res = 0, mv_cnt;
Move mvs[32];
Bool king_stalemate = TRUE;

for (i = 0; i < 32; i++)
{
if (state->pieces[i].player == state->cur_player)
{
mv_cnt = PieceMoves(state, i, mvs);
mv_cnt = ChkPieceMoves(state, i, mvs,mv_cnt);
res += mv_cnt;
}
return res;
if (state->pieces[i].type != P_KING && state->pieces[i].player >= 0)
king_stalemate = FALSE;
}
if (king_stalemate)
return 0;
else
return res;
}


U0 DrawIt(CTask *task, CDC *dc)
{
I64 i, x, y, z, k0, k1;
Expand Down
20 changes: 18 additions & 2 deletions src/Home/Net/Drivers/PCNet.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#define PCNET_INT_TINTM 9 // Transmit Interrupt Mask
#define PCNET_INT_RINTM 10 // Receive Interrupt Mask

#define PCNET_FEATURE_ASTRPRCV 10
#define PCNET_FEATURE_APADXMT 11

#define PCNET_BCR_MISC_CONFIG_ASEL 1
Expand Down Expand Up @@ -455,7 +456,7 @@ U0 PCNetInterruptCSRSet()
U0 PCNetTXAutoPadEnable()
{/* AMD PCNet datasheet p.1-958
Setting bit 11 (Auto Pad Transmit) allows
shoft transmit frames to be automatically
short transmit frames to be automatically
extended to 64 bytes. */

U32 csr = PCNetCSRRead(PCNET_CSR_FEATURECTRL);
Expand All @@ -465,6 +466,19 @@ U0 PCNetTXAutoPadEnable()
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()
{/* AMD PCNet datasheet p.1-954
PCNet controller can be started
Expand Down Expand Up @@ -749,6 +763,8 @@ U0 PCNetInit()

PCNetTXAutoPadEnable;

PCNetRXAutoStripEnable;

PCNetAutoLinkSelect;

PCNetEnableFullDuplex;
Expand Down Expand Up @@ -845,4 +861,4 @@ U0 NetStart()
PCNetCSRWrite(PCNET_CSR_CTRLSTATUS, csr);
}

PCNetInit;
PCNetInit;
19 changes: 9 additions & 10 deletions src/Home/Net/Protocols/Ethernet.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@ U0 EthernetGlobalsInit()
}
}

//TODO: check length , figure out the length+4
U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
{
//TODO: Check length ! We need to figure out what
//lengths are appropriate

//Shrine also says MemCopy has a
//high overhead. Almost tempted to say that means that a lot
//of the current system should be done with less extra allocation
//altogether, more passing.
//In practice, MemCopy causes the most slowdown on bare-metal.
// Shrine says MemCopy has a high overhead.
// Almost tempted to say that means that a lot
// of the current system should be done with
// less extra allocation altogether, more passing.
// In practice, MemCopy causes the most slowdown on bare-metal.

NetLog("ETHERNET FRAME PARSE: Parsing frame, copying out to frame_out param.");

Expand All @@ -49,7 +45,10 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)

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?
if (frame_out->ethertype <= ETHERNET_v2_MTU) // check if the field is a length or an ethertype
frame_out->length = frame_out->ethertype;
else
frame_out->length = length - ETHERNET_MAC_HEADER_LENGTH - FCS_LENGTH;
}

U0 EthernetFrameFinish(I64 de_index)
Expand Down
3 changes: 3 additions & 0 deletions src/Home/Net/Utilities/Net.HH
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#define ETHERNET_ETHERTYPE_OFFSET 12
#define ETHERNET_DATA_OFFSET 14
#define MAC_ADDRESS_LENGTH 6
#define FCS_LENGTH 4

/* 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. */
#define ETHERNET_FRAME_SIZE 2000

#define ETHERNET_v2_MTU 1500

#define HTYPE_ETHERNET 1
#define HLEN_ETHERNET 6
#define PLEN_IPV4 4
Expand Down
10 changes: 10 additions & 0 deletions src/Home/Net/Utilities/NetHandler.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ U0 NetQueueEntryHandle(CNetQueueEntry *entry)

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)
{
case ETHERTYPE_ARP:
Expand Down
1 change: 1 addition & 0 deletions src/Kernel/BlkDev/DiskAHCI.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ I64 AHCIAtapiCapacityGet(CBlkDev *bd)
cmd_fis->type = FISt_H2D;
PCIBts(&cmd_fis->desc, AHCI_CF_DESCf_C); //Set Command bit in H2D FIS.
cmd_fis->command = ATA_PACKET;
cmd_fis->lba1 = 8;
cmd_table->acmd[0] = ATAPI_READ_CAPACITY >> 8;

AHCIPortWait(bd->port_num, tS + 2);
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/KGlobals.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
CDate local_time_offset;
F64 *pow10_I64,
sys_os_version = 2.03;
U64 sys_os_version_sub = 109;
U64 sys_os_version_sub = 113;
U8 *sys_os_version_str;
U8 *sys_os_version_full;
U8 *sys_os_version_nice;
Expand Down

0 comments on commit 1b7f2bb

Please sign in to comment.