diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..3f539841 --- /dev/null +++ b/.github/workflows/build.yml @@ -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" diff --git a/README.md b/README.md index 08c6cae6..d9a27101 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build/AUTO.ISO b/build/AUTO.ISO index eeb24e6e..c523bff2 100755 Binary files a/build/AUTO.ISO and b/build/AUTO.ISO differ diff --git a/build/build-iso.sh b/build/build-iso.sh index 3535c830..80bf3d97 100755 --- a/build/build-iso.sh +++ b/build/build-iso.sh @@ -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 @@ -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 @@ -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" @@ -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 @@ -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 diff --git a/build/git-pr-switch.sh b/build/git-pr-switch.sh index d5b3585b..44dec00b 100755 --- a/build/git-pr-switch.sh +++ b/build/git-pr-switch.sh @@ -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 diff --git a/build/sync.sh b/build/sync.sh index 152cb605..bc10401f 100755 --- a/build/sync.sh +++ b/build/sync.sh @@ -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) diff --git a/src/Demo/Games/Chess.ZC b/src/Demo/Games/Chess.ZC index 9d5a5360..6af8908e 100755 --- a/src/Demo/Games/Chess.ZC +++ b/src/Demo/Games/Chess.ZC @@ -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) @@ -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; diff --git a/src/Home/Net/Drivers/PCNet.ZC b/src/Home/Net/Drivers/PCNet.ZC index 7ca8b800..bf84da61 100755 --- a/src/Home/Net/Drivers/PCNet.ZC +++ b/src/Home/Net/Drivers/PCNet.ZC @@ -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 @@ -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); @@ -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 @@ -749,6 +763,8 @@ U0 PCNetInit() PCNetTXAutoPadEnable; + PCNetRXAutoStripEnable; + PCNetAutoLinkSelect; PCNetEnableFullDuplex; @@ -845,4 +861,4 @@ U0 NetStart() PCNetCSRWrite(PCNET_CSR_CTRLSTATUS, csr); } -PCNetInit; \ No newline at end of file +PCNetInit; diff --git a/src/Home/Net/Protocols/Ethernet.ZC b/src/Home/Net/Protocols/Ethernet.ZC index 3a4de9f0..611b3b34 100755 --- a/src/Home/Net/Protocols/Ethernet.ZC +++ b/src/Home/Net/Protocols/Ethernet.ZC @@ -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."); @@ -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) diff --git a/src/Home/Net/Utilities/Net.HH b/src/Home/Net/Utilities/Net.HH index 677f37ac..0953fd61 100755 --- a/src/Home/Net/Utilities/Net.HH +++ b/src/Home/Net/Utilities/Net.HH @@ -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 diff --git a/src/Home/Net/Utilities/NetHandler.ZC b/src/Home/Net/Utilities/NetHandler.ZC index fad866ad..f7dc2061 100755 --- a/src/Home/Net/Utilities/NetHandler.ZC +++ b/src/Home/Net/Utilities/NetHandler.ZC @@ -37,6 +37,16 @@ U0 NetQueueEntryHandle(CNetQueueEntry *entry) EthernetFrameParse(ðernet_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: diff --git a/src/Kernel/BlkDev/DiskAHCI.ZC b/src/Kernel/BlkDev/DiskAHCI.ZC index 7832501a..8cd23fa2 100755 --- a/src/Kernel/BlkDev/DiskAHCI.ZC +++ b/src/Kernel/BlkDev/DiskAHCI.ZC @@ -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); diff --git a/src/Kernel/KGlobals.ZC b/src/Kernel/KGlobals.ZC index e87446d1..c794b0eb 100755 --- a/src/Kernel/KGlobals.ZC +++ b/src/Kernel/KGlobals.ZC @@ -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;