forked from uiaict/2024-ikt218-osdev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a6d65b1
Showing
46 changed files
with
2,817 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
|
||
|
||
# Stage 1: Building Bochs | ||
FROM ubuntu:22.04 as bochs-builder | ||
|
||
# Update and install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
build-essential \ | ||
libgtk2.0-dev \ | ||
libncurses5-dev \ | ||
libncursesw5-dev \ | ||
libsdl2-dev | ||
|
||
# Clone and build Bochs | ||
RUN git clone https://github.com/bochs-emu/Bochs && cd Bochs/bochs && \ | ||
./configure --enable-smp \ | ||
--enable-cpu-level=6 \ | ||
--enable-all-optimizations \ | ||
--enable-x86-64 \ | ||
--enable-pci \ | ||
--enable-vmx \ | ||
--enable-debugger \ | ||
--enable-disasm \ | ||
--enable-debugger-gui \ | ||
--enable-logging \ | ||
--enable-fpu \ | ||
--enable-3dnow \ | ||
--enable-sb16=dummy \ | ||
--enable-cdrom \ | ||
--enable-x86-debugger \ | ||
--enable-iodebug \ | ||
--disable-plugins \ | ||
--disable-docbook \ | ||
--with-x \ | ||
--with-x11 \ | ||
--with-term \ | ||
--with-sdl2 && \ | ||
make | ||
|
||
|
||
FROM ubuntu:22.04 as gcc-builder | ||
ARG BINUTILS_VERSION=2.41 | ||
ARG GCC_VERSION=13.2.0 | ||
|
||
# Set the ARGs as environment variables and write them to a file | ||
RUN echo "BINUTILS_VERSION=$BINUTILS_VERSION" > /version_env | ||
RUN echo "GCC_VERSION=$GCC_VERSION" >> /version_env | ||
|
||
COPY ./files/src /usr/local/src/ | ||
COPY ./files/gcc/t-x86_64-elf /usr/local/src/gcc-${GCC_VERSION}/gcc/config/i386/ | ||
COPY ./files/gcc/config.gcc.patch /usr/local/src/gcc-${GCC_VERSION}/gcc/ | ||
|
||
# Install cross-compiler prerequisites and remove them in the same RUN command to keep the layer size small | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y \ | ||
wget \ | ||
gcc \ | ||
libgmp3-dev \ | ||
libmpfr-dev \ | ||
libisl-dev \ | ||
libmpc-dev \ | ||
texinfo bison \ | ||
flex \ | ||
make \ | ||
bzip2 \ | ||
patch \ | ||
build-essential \ | ||
&& mkdir -p /usr/local/src \ | ||
&& mkdir -p /usr/local/gcc-install \ | ||
&& cd /usr/local/src \ | ||
&& wget -q https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz \ | ||
&& wget -q https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz \ | ||
&& tar zxf binutils-${BINUTILS_VERSION}.tar.gz \ | ||
&& tar zxf gcc-${GCC_VERSION}.tar.gz \ | ||
&& rm binutils-${BINUTILS_VERSION}.tar.gz gcc-${GCC_VERSION}.tar.gz \ | ||
&& chown -R root:root binutils-${BINUTILS_VERSION} \ | ||
&& chown -R root:root gcc-${GCC_VERSION} \ | ||
&& chmod -R o-w,g+w binutils-${BINUTILS_VERSION} \ | ||
&& chmod -R o-w,g+w gcc-${GCC_VERSION} \ | ||
&& cd /usr/local/src \ | ||
&& bash build-binutils.sh ${BINUTILS_VERSION} /usr/local \ | ||
&& bash build-gcc.sh ${GCC_VERSION} /usr/local \ | ||
# Now remove the build dependencies | ||
&& apt-get purge -y --auto-remove \ | ||
wget \ | ||
gcc \ | ||
texinfo bison \ | ||
flex \ | ||
make \ | ||
bzip2 \ | ||
patch \ | ||
libisl-dev \ | ||
libmpc-dev \ | ||
build-essential \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
|
||
FROM ubuntu:22.04 as devcontainer | ||
RUN apt-get update && apt-get install -y \ | ||
libgtk2.0-0 \ | ||
libncurses5 \ | ||
libsdl2-2.0-0 \ | ||
git \ | ||
sudo \ | ||
make \ | ||
cmake \ | ||
nasm \ | ||
ninja-build \ | ||
xorriso \ | ||
qemu \ | ||
qemu-kvm \ | ||
qemu-system-x86 \ | ||
qemu \ | ||
gdb-multiarch \ | ||
tmux \ | ||
dosfstools \ | ||
libisl-dev \ | ||
libmpc-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy GCC installation from the first stage | ||
COPY --from=gcc-builder /usr/local/src /usr/local/src | ||
RUN cd /usr/local/src/build-binutils && make install && cd /usr/local/src/build-gcc && make install-gcc && make install-target-libgcc | ||
|
||
|
||
# Copy Bochs binaries from the builder stage | ||
COPY --from=bochs-builder /Bochs/bochs/bochs /usr/local/bin/ | ||
COPY --from=bochs-builder /Bochs/bochs/bximage /usr/local/bin/ | ||
COPY --from=bochs-builder /Bochs/bochs/bios/BIOS-bochs-latest /usr/local/share/bochs/BIOS-bochs-latest | ||
COPY --from=bochs-builder /Bochs/bochs/bios/VGABIOS-lgpl-latest /usr/local/share/bochs/VGABIOS-lgpl-latest | ||
|
||
# Download the latest Limine binary release. | ||
RUN cd /usr/local && git clone https://github.com/limine-bootloader/limine.git --branch=v6.x-branch-binary --depth=1 && make -C limine | ||
|
||
|
||
|
||
RUN groupadd -g 61000 osdev; \ | ||
useradd -g 61000 -l -m -s /bin/bash -u 61000 osdev; \ | ||
mkdir -p /home/osdev/supervisor; \ | ||
touch /home/osdev/.Xauthority; \ | ||
chown -R osdev:osdev /home/osdev;\ | ||
chmod -R 777 /home/osdev ;\ | ||
adduser osdev sudo;\ | ||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers; | ||
|
||
RUN apt-get remove -y gcc && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Set default command to launch Supervisor | ||
COPY ./files/entrypoint.sh /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh && chown osdev:osdev /usr/local/bin/entrypoint.sh | ||
|
||
# LIBGL_ALWAYS_INDIRECT=1 | ||
ENV LIBGL_ALWAYS_INDIRECT=1 | ||
|
||
|
||
USER osdev | ||
WORKDIR /home/osdev | ||
|
||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
|
||
|
||
|
||
|
||
# Create GUI | ||
FROM devcontainer as devcontainer-webgui | ||
|
||
USER root | ||
|
||
ENV DISPLAY=:1 \ | ||
VNC_PORT=5901 \ | ||
NO_VNC_PORT=6901 \ | ||
VNC_COL_DEPTH=32 \ | ||
VNC_RESOLUTION=1920x1080 \ | ||
TERM=xterm \ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
NOVNC_VERSION="v1.4.0" \ | ||
WEBSOCKIFY_VERSION="v0.11.0" | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
supervisor \ | ||
xvfb \ | ||
xauth \ | ||
dbus-x11 \ | ||
xfce4 \ | ||
xfce4-terminal \ | ||
x11-xserver-utils \ | ||
x11-utils \ | ||
tigervnc-standalone-server \ | ||
tigervnc-common \ | ||
python3-numpy \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
|
||
# Install NOVNC. | ||
RUN git clone --branch ${NOVNC_VERSION} --single-branch https://github.com/novnc/noVNC.git /opt/noVNC; \ | ||
git clone --branch ${WEBSOCKIFY_VERSION} --single-branch https://github.com/novnc/websockify.git /opt/noVNC/utils/websockify; \ | ||
ls -la /opt/noVNC; \ | ||
ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html | ||
|
||
|
||
# Supervisor configuration files | ||
COPY ./files/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
COPY ./files/supervisor/novnc.conf /etc/supervisor/conf.d/novnc.conf | ||
COPY ./files/supervisor/vncserver.conf /etc/supervisor/conf.d/vncserver.conf | ||
# Expose VNC and noVNC ports | ||
EXPOSE ${VNC_PORT} ${NO_VNC_PORT} | ||
|
||
USER osdev | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Guide 1 /////////////////////////////////////////////////////////// | ||
// MacOS - X Forwarding | ||
// https://gist.github.com/cschiewek/246a244ba23da8b9f0e7b11a68bf3285 | ||
// 1. brew install --cask xquartz | ||
////////////////////////////////////////////////////////////////////// | ||
{ | ||
"name": "Ubuntu", | ||
"postStartCommand": "/usr/local/bin/entrypoint.sh", | ||
"remoteUser": "osdev", | ||
"features": {}, | ||
"forwardPorts": [], | ||
|
||
//////////////////////////////////// | ||
// UNCOMMENT to use prebuilt image | ||
//////////////////////////////////// | ||
"image": "ghcr.io/uiaict/2024-ikt218-osdev/devcontainer:2776417", | ||
|
||
//////////////////////////////////// | ||
// UNCOMMENT to build manually | ||
//////////////////////////////////// | ||
//"build": { | ||
// "dockerfile": "Dockerfile", | ||
// "target": "devcontainer" | ||
//}, | ||
|
||
|
||
//////////////////////////////////// | ||
// Uncomment on linux and macOS | ||
//////////////////////////////////// | ||
"mounts": [ | ||
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached", | ||
"source=/mnt/wslg,target=/mnt/wslg,type=bind,consistency=cached" | ||
], | ||
|
||
//////////////////////////////////// | ||
// UNCOMMENT ON LINUX AND WINDOWS (wsl2) | ||
//////////////////////////////////// | ||
"containerEnv": { | ||
"DISPLAY": "host.docker.internal:0", | ||
"PULSE_SERVER": "/mnt/wslg/PulseServer" | ||
}, | ||
|
||
//////////////////////////////////// | ||
// UNCOMMENT ON MAC | ||
//////////////////////////////////// | ||
//"containerEnv": { | ||
// "DISPLAY": "docker.for.mac.host.internal:0" | ||
//}, | ||
|
||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cmake-tools", | ||
"ms-azuretools.vscode-docker", | ||
"ms-vscode-remote.remote-containers", | ||
"twxs.cmake", | ||
"ms-vscode.cpptools", | ||
"ms-vscode.cpptools-extension-pack", | ||
"GitHub.copilot", | ||
"webfreak.debug", | ||
"13xforever.language-x86-64-assembly", | ||
"DamianKoper.gdb-debug" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Start supervisord in the background and redirect its output to /dev/null | ||
|
||
# open supervisord in tmux | ||
tmux new-session -d -s supervisord | ||
tmux send-keys -t supervisord "/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf" C-m | ||
|
||
# End of entrypoint | ||
# ----------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- config.gcc 2016-04-11 03:14:59.000000000 -0700 | ||
+++ config.gcc.new 2016-04-27 13:47:22.444331746 -0700 | ||
@@ -1420,6 +1420,7 @@ | ||
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h" | ||
;; | ||
x86_64-*-elf*) | ||
+ tmake_file="${tmake_file} i386/t-x86_64-elf" # include the new multilib configuration | ||
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h" | ||
;; | ||
x86_64-*-rtems*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Add libgcc multilib variant without red-zone requirement | ||
|
||
MULTILIB_OPTIONS += mno-red-zone | ||
MULTILIB_DIRNAMES += no-red-zone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
BINUTILS_VERSION=$1 | ||
|
||
|
||
export PREFIX=$2 | ||
#export TARGET=x86_64-elf | ||
export TARGET=i686-elf | ||
export PATH="$PREFIX/bin:$PATH" | ||
|
||
cd $PREFIX/src | ||
mkdir build-binutils | ||
cd build-binutils | ||
../binutils-${BINUTILS_VERSION}/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror | ||
make -j `nproc` | ||
make install | ||
|
||
cd $PREFIX/src | ||
#rm -rf build-binutils.sh binutils-${BINUTILS_VERSION} | ||
# rm -rf build-binutils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
GCC_VERSION=$1 | ||
|
||
export PREFIX=$2 | ||
#export TARGET=x86_64-elf | ||
export TARGET=i686-elf | ||
export PATH="$PREFIX/bin:$PATH" | ||
|
||
cd $PREFIX/src/gcc-${GCC_VERSION}/gcc | ||
patch < config.gcc.patch | ||
|
||
cd $PREFIX/src | ||
mkdir build-gcc | ||
cd build-gcc | ||
../gcc-${GCC_VERSION}/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers | ||
make -j `nproc` all-gcc | ||
make -j `nproc` all-target-libgcc | ||
make install-gcc | ||
make install-target-libgcc | ||
|
||
cd $PREFIX/src | ||
#rm -rf build-gcc.sh gcc-${GCC_VERSION} | ||
# rm -rf build-gcc |
Empty file.
Oops, something went wrong.