#!/bin/bash

#
# File .......... swuk_repos_fix_headers
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 25 Mar 2025
# Version ....... 1.0
# Description ...
#   Edit the headers in a split repository using the 'ed' command. Core function
# is basically the output from swuk_repos_gen_fix_headers, edited by hand to add
# the missing information.
#

# Strict
set -euo pipefail

################################################################################
# Edit the headers.
# Arguments ...... None
# Return ......... None
# Shared (In) .... None
# Shared (Out) ... None
edit_headers()
{
#### 0001 - Part 1 #############################################################

ed 0001/common/fw/src/script/create_vivado_project.sh <<END
3,15d
.
2a
#
# File .......... create_vivado_project.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 03 May 2021
# Version ....... 1.0
# Description ...
#   Very simple script to launch Vivado and run the TCL script. Should be run
# in the project host directory that contains the fw & sw subdirectories, for
# example :-
#
# user@host:~/projects/project$ create_vivado_project.sh
# user@host:~/projects/project$ create_vivado_project.sh build
#
.
wq
END

ed 0001/common/fw/src/script/create_vivado_project.tcl <<END
1,9d
.
0a
#
# File .......... create_vivado_project.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 23 Dec 2021
# Version ....... 1.0
# Description ...
#   Simple Tcl script to create a new Vivado project, import external
# sources and (optionally) generate the bitstream & export the hardware.
#
.
wq
END

ed 0001/common/other/src/script/create_project_structure.sh <<END
4,13d
.
3a
#
# File .......... create_project_structure.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 29 Dec 2021
# Version ....... 1.0
# Description ...
#   Simple script to create a possible project directory structure for combined
# firmware, hardware, operating system & software development. Very much work
# in progress and by all means not a golden solution to anything.
#
.
wq
END

ed 0001/common/other/src/script/xilinx.sh <<END
3,12d
.
2a
#
# File .......... xilinx.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 08 Feb 2021
# Version ....... 1.0
# Description ...
#   Determine and list which Xilinx tools are available and let the user select
# the require ones to use. Does not reverse any previously selected tools upon
# selecting news ones so to is cleaner to use in a new Terminal session.
#
.
wq
END

ed 0001/common/other/src/script/xilinx_2021_2.sh <<END
2a
#
# File .......... xilinx_2021_2.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 08 Feb 2021
# Version ....... 1.0
# Description ...
#   Setup for the 2021.2 Xilinx tools.
#

.
wq
END

ed 0001/common/sw/src/script/create_vitis_project.sh <<END
3,15d
.
2a
#
# File .......... create_vitis_project.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 03 May 2021
# Version ....... 1.0
# Description ...
#   Very simple script to launch the Xilinx software command-line tool,
# run the TCL script and launch Vitis. Should be run in the project host
# directory that contains the fw & sw subdirectories, for example :-
#
# user@host:~/projects/project$ create_vitis_project.sh
# user@host:~/projects/project$ create_vitis_project.sh build
#
.
wq
END

ed 0001/common/sw/src/script/create_vitis_project.tcl <<END
1,9d
.
0a
#
# File .......... create_vitis_project.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 21 Dec 2021
# Version ....... 1.0
# Description ...
#   Simple Tcl script to create a new Vitis application, import external
# sources and (optionally) build the application.
#
.
wq
END

#### 0002 - Part 2 #############################################################

ed 0002/zedboard_hello_world/sw/src/c/hello_world.c <<END
1,8d
.
0a
//
// File .......... hello_world.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Hello World (SpaceWire UK Tutorial)
// Date .......... 27 Dec 2021
// Version ....... 1.0
// Description ...
//   The classic hello world C application.
//
.
wq
END

#### 0003 - Part 3 #############################################################

ed 0003/common/fw/src/script/zedboard_presets.tcl <<END
0a
#
# File .......... zedboard_presets.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 22 Dec 2021
# Version ....... 1.0
# Description ...
#   ZYNQ7 Processing System presets, as set by the Zedboard BSP.
#

.
wq
END

ed 0003/zedboard_leds_switches/fw/src/constraint/zedboard.xdc <<END
0a
#
# File .......... zedboard.xdc
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
# Date .......... 22 Dec 2021
# Version ....... 1.0
# Description ...
#   Pin & timing constraints for the Zedboard LEDs & Switches design.
#

.
wq
END

ed 0003/zedboard_leds_switches/fw/src/testbench/testbench.sv <<END
1,10d
.
0a
//
// File .......... testbench.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 22 Dec 2021
// Version ....... 1.0
// Description ...
//   Very simple testbench to check correct connectivity of the block diagram.
// Uses the Zynq Verification IP suite to read/write the GPIO LED register and
// read the GPIO switch register.
//
.
wq
END

ed 0003/zedboard_leds_switches/sw/src/c/zedboard_leds_switches.c <<END
1,8d
.
0a
//
// File .......... zedboard_leds_switches.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 15 Jan 2022
// Version ....... 1.0
// Description ...
//   Very simple LEDs & Switches example design.
//
.
wq
END

#### 0004 - Part 4 #############################################################

ed 0004/zedboard_leds_buttons/fw/src/constraint/zedboard.xdc <<END
0a
#
# File .......... zedboard.xdc
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Buttons (SpaceWire UK Tutorial)
# Date .......... 22 Dec 2021
# Version ....... 1.0
# Description ...
#   Pin & timing constraints for the Zedboard LEDs & Buttons design.
#

.
wq
END

ed 0004/zedboard_leds_buttons/fw/src/testbench/testbench.sv <<END
1,10d
.
0a
//
// File .......... testbench.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Buttons (SpaceWire UK Tutorial)
// Date .......... 22 Dec 2021
// Version ....... 1.0
// Description ...
//   Very simple testbench to check correct connectivity of the block diagram.
// Uses the Zynq Verification IP suite to read/write the GPIO LED register and
// read the GPIO switch register.
//
.
wq
END

ed 0004/zedboard_leds_buttons/sw/src/c/zedboard_leds_buttons.c <<END
1,8d
.
0a
//
// File .......... zedboard_leds_buttons.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Buttons (SpaceWire UK Tutorial)
// Date .......... 15 Jan 2022
// Version ....... 1.0
// Description ...
//   Very simple LEDs & Push Buttons interrupt example design.
//
.
wq
END

#### 0005 - Part 5 #############################################################

ed 0005/zedboard_linux/os/petalinux/project-spec/meta-user/conf/petalinuxbsp.conf <<END
0a
#
# File .......... petalinuxbsp.conf
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 17 Jan 2022
# Version ....... 1.0
# Description ...
#   Updated to install the following :-
# -- ntp ....... Network Time Protocol
# -- ntpdate ... Set the date and time via NTP
# -- ntpq ...... Standard NTP query program
# -- sntp ...... Simple Network Time Protocol
#

.
wq
END

#ed 0005/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi <<END
#0a
#/*
# * File .......... system-user.dtsi
# * Author ........ Steve Haywood
# * Website ....... http://www.spacewire.co.uk
# * Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# * Date .......... Sage date!
# * Version ....... 1.0
# * Description ...
# *   Sage words!
# */
#
#.
#wq
#END

#### 0006 - Part 6 #############################################################

#### 0007 - Part 7 #############################################################

ed 0007/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/led-runner/files/led-runner <<END
2a
#
# File .......... led-runner
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 18 Jan 2022
# Version ....... 1.0
# Description ...
#   Expanding & contracting LED sequence using the GPIO located at 0x4120_0000.
#

.
wq
END

ed 0007/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/led-runner/led-runner.bb <<END
1,3d
.
0a
#
# File .......... led-runner.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 18 Jan 2022
# Version ....... 1.0
# Description ...
#   Recipe for an autostart application.
#

.
wq
END

#### 0008 - Part 8a ############################################################

ed 0008/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/index.html <<END
0a
<!--
// File .......... index.html
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 21 Jan 2022
// Version ....... 1.0
// Description ...
//   Simple hello world in HTML that displays the Zedboard image.
-->

.
wq
END

ed 0008/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 1.0
# Description ...
#   Application recipe for a basic website that consists of a webpage (html) & an
# image of the Zedboard (png).
#

.
wq
END

#### 0009 - Part 8b ############################################################

ed 0009/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 1.0
# Description ...
#   Dynamic (server side) webpage to display system information from PetaLinux
# running on the Zedboard.
#

.
wq
END

ed 0009/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 2.0
# Description ...
#   Application recipe for a dynamic (server side) webpage that consists of a
# webpage (cgi) & an image of the Zedboard (png).
#

.
wq
END

#### 0010 - Part 8c ############################################################

ed 0010/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 2.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Updated to add a widget that displays the
# uptime of PetaLinux.
#

.
wq
END

ed 0010/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/uptime.cgi <<END
2a
#
# File .......... uptime.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 1.0
# Description ...
#   Simple CGI to provide the system uptime.
#

.
wq
END

ed 0010/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 21 Jan 2022
// Version ....... 1.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage.
//

.
wq
END

ed 0010/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 21 Jan 2022
# Version ....... 3.0
# Description ...
#   Application recipe for a dynamic (server & client side) webpage that consists
# of a webpage (cgi), uptime script (cgi), support functions (js) & an image of
# the Zedboard (png).
#

.
wq
END

#### 0011 - Part 10 ############################################################

ed 0011/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/Makefile <<END
0a
#
# File .......... Makefile
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 05 Mar 2022
# Version ....... 1.0
# Description ...
#   Makefile for the peek & poke CGI binaries.
#

.
wq
END

ed 0011/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/peek.c <<END
1,9d
.
0a
//
// File .......... peek.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 26 Nov 2021
// Version ....... 1.0
// Description ...
//   Very simple CGI peek application for single 32-bit reads. Provides
// status & error reporting back to the client side application.
//
.
wq
END

ed 0011/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/poke.c <<END
1,9d
.
0a
//
// File .......... poke.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 26 Nov 2021
// Version ....... 1.0
// Description ...
//   Very simple CGI poke application for single 32-bit writes. Provides
// status & error reporting back to the client side application.
//
.
wq
END

ed 0011/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/peekpokecgi.bb <<END
1,5d
.
0a
#
# File .......... peekpokecgi.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 05 Mar 2022
# Version ....... 1.0
# Description ...
#   Application recipe for the peek & poke CGI binaries.
#

.
wq
END

#### 0012 - Part 11 ############################################################

ed 0012/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 06 Mar 2022
# Version ....... 3.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Already includes a widget that displays the
# uptime of PetaLinux.  Updated to add extra widgets to read & write register
# functionality.
#

.
wq
END

ed 0012/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 06 Mar 2022
// Version ....... 2.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly.
//

.
wq
END

#### 0013 - Part 12 ############################################################

ed 0013/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 07 Mar 2022
# Version ....... 4.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Already includes a widget that displays the
# uptime of PetaLinux and widgets to read & write register functionality.
# Updated to use a style sheet for a more improved look.
#

.
wq
END

ed 0013/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/styles.css <<END
0a
/*
 * File .......... styles.css
 * Author ........ Steve Haywood
 * Website ....... http://www.spacewire.co.uk
 * Project ....... Zedboard Linux (SpaceWire UK Tutorial)
 * Date .......... 07 Mar 2022
 * Version ....... 1.0
 * Description ...
 *   Introduction of a style sheet to separate out the embedded styles from the
 * webpage. Much more flexible and easier to maintain.
 */

.
wq
END

ed 0013/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 07 Mar 2022
# Version ....... 4.0
# Description ...
#   Application recipe for a dynamic (server & client side) webpage that consists
# of a webpage (cgi), uptime script (cgi), support functions (js), styles (css) &
# an image of the Zedboard (png).
#

.
wq
END

#### 0014 - Part 13a ###########################################################

ed 0014/zedboard_leds_switches/fw/src/testbench/testbench.sv <<END
1,10d
.
0a
//
// File .......... testbench.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 17 Jun 2022
// Version ....... 2.0
// Description ...
//   Very simple testbench to check correct connectivity of the block diagram.
// Uses the Zynq Verification IP suite to read/write the GPIO LED register and
// read the GPIO switch register.
//
.
wq
END

#### 0015 - Part 13b ###########################################################

ed 0015/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 17 Jun 2022
# Version ....... 5.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Already includes a widget that displays the
# uptime of PetaLinux and widgets to read & write register functionality. Also
# uses a style sheet for a more improved look. Enhanced the peek & poke
# capabilities such that multiple registers can be accessed. Added in global
# controls for the multiple registers and also file access so the register
# configuration can be saved and re-loaded.
#

.
wq
END

ed 0015/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 17 Jun 2022
// Version ....... 3.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly. Enhanced functions to
// improve webpage look & feel, including the use of new status animation images
// for success/fail of register read/write calls and also a register
// configuration save & re-load facility.
//

.
wq
END

ed 0015/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 17 Jun 2022
# Version ....... 5.0
# Description ...
#   Application recipe for a dynamic (server & client side) webpage that consists
# of a webpage (cgi), uptime script (cgi), support functions (js), styles (css),
# an image of the Zedboard (png) & 3 status animation images (gif).
#

.
wq
END

#### 0016 - Part 14a ###########################################################

ed 0016/zedboard_leds_switches/fw/src/design/axi_identification.v <<END
1,20d
.
0a
//
// File .......... axi_identification.v
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 05 Dec 2021
// Version ....... 1.0
// Description ...
//   AXI4-Lite controlled register bank written in basic Verilog. The register
// bank contains the following fixed length identification and timestamp
// strings.
//
// Product Description ........ 128 Characters - 32 Registers - 0x000 - 0x07F
// Company ....................  64 Characters - 16 Registers - 0x080 - 0x0BF
// Author .....................  64 Characters - 16 Registers - 0x0C0 - 0x0FF
// Product Version ............  16 Characters -  4 Registers - 0x100 - 0x10F
// Firmware Build Timestamp ...  32 Characters -  8 Registers - 0x110 - 0x12F
// Unused ..................... 208 Characters - 52 Registers - 0x130 - 0x1FF
//                              ---              ---            -------------
//                              512              128          - 0x000 - 0x1FF
//
.
wq
END

ed 0016/zedboard_leds_switches/fw/src/diagram/system/hdl/system_wrapper.sv <<END
1,9d
.
0a
//
// File .......... system_wrapper.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 06 Dec 2021
// Version ....... 1.0
// Description ...
//   Top level wrapper for the underlying block design.
//
.
wq
END

ed 0016/zedboard_leds_switches/fw/src/script/post_bit.tcl <<END
1,10d
.
0a
#
# File .......... post_bit.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
# Date .......... 24 Oct 2021
# Version ....... 1.0
# Description ...
#   Script to replace 'project.txt' (Information about last version of firmware)
# with 'project_new.txt' (Information about new version of firmware). The file
# replace only occurs if the bitstream was generated successfully.
#
.
wq
END

ed 0016/zedboard_leds_switches/fw/src/script/pre_synth.tcl <<END
1,10d
.
0a
#
# File .......... pre_synth.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
# Date .......... 24 Oct 2021
# Version ....... 1.0
# Description ...
#   Script to read product/project information from a text file, increase
# the version/revision, get current timestamp and set the generics/parameters
# on the top level module.
#
.
wq
END

ed 0016/zedboard_leds_switches/fw/src/testbench/testbench.sv <<END
1,10d
.
0a
//
// File .......... testbench.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 13 Sep 2022
// Version ....... 3.0
// Description ...
//   Very simple testbench to check correct connectivity of the block diagram.
// Uses the Zynq Verification IP suite to read/write the GPIO LED register and
// read the GPIO switch register.
//
.
wq
END

#### 0017 - Part 14b ###########################################################

ed 0017/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/Makefile <<END
0a
#
# File .......... Makefile
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 13 Sep 2022
# Version ....... 2.0
# Description ...
#   Makefile for the peek, poke & peekstring CGI binaries.
#

.
wq
END

ed 0017/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/peekstring.c <<END
1,14d
.
0a
//
// File .......... peekstring.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2021
// Version ....... 1.0
// Description ...
//   CGI type module to read a string from memory and return it.
// Usage ...
//   http://<web address>/cgi-bin/peekstring?base&size&offset&maxchars
// base = Base address of memory region to be used
// size = Size of memory region to be used
// offset = Offset address of string within memory region
// maxchars = Maximum length of return string
//
.
wq
END

ed 0017/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/peekpokecgi.bb <<END
1,5d
.
0a
#
# File .......... peekpokecgi.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 13 Sep 2022
# Version ....... 2.0
# Description ...
#   Application recipe for the peek, poke & peekstring CGI binaries.
#

.
wq
END

ed 0017/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 13 Sep 2022
# Version ....... 6.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Already includes a widget that displays the
# uptime of PetaLinux and widgets to read & write register functionality. Also
# uses a style sheet for a more improved look. Enhanced the peek & poke
# capabilities such that multiple registers can be accessed. Added in global
# controls for the multiple registers and also file access so the register
# configuration can be saved and re-loaded. Added a Product Information
# section for the Firmware.
#

.
wq
END

ed 0017/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 13 Sep 2022
// Version ....... 4.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly. Enhanced functions to improve
// webpage look & feel, including the use of new status animation images for
// success/fail of register read/write calls and also a register configuration
// save & re-load facility. Added the functions required to support reading
// strings from the PL address space and dynamically updating the the webpage
// accordingly.
//

.
wq
END

#### 0018 - Part 16a ###########################################################

ed 0018/zedboard_leds_switches/fw/src/design/axi_identification.v <<END
1,21d
.
0a
//
// File .......... axi_identification.v
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 02 Oct 2022
// Version ....... 2.0
// Description ...
//   AXI4-Lite controlled register bank written in basic Verilog. The register
// bank contains the following fixed length identification and timestamp
// strings.
//
// Description ................ 128 Characters - 32 Registers - 0x000 - 0x07F
// Company ....................  64 Characters - 16 Registers - 0x080 - 0x0BF
// Author .....................  64 Characters - 16 Registers - 0x0C0 - 0x0FF
// Version ....................  32 Characters -  8 Registers - 0x100 - 0x11F
// Timestamp ..................  32 Characters -  8 Registers - 0x120 - 0x13F
// Hash .......................  64 Characters - 16 Registers - 0x140 - 0x17F
// Unused ..................... 144 Characters - 36 Registers - 0x180 - 0x20F
//                              ---              ---            -------------
//                              528              132          - 0x000 - 0x20F
//
.
wq
END

ed 0018/zedboard_leds_switches/fw/src/diagram/system/hdl/system_wrapper.sv <<END
1,9d
.
0a
//
// File .......... system_wrapper.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 02 Oct 2022
// Version ....... 2.0
// Description ...
//   Top level wrapper for the underlying block design.
//
.
wq
END

ed 0018/zedboard_leds_switches/fw/src/script/pre_synth.tcl <<END
1,10d
.
0a
#
# File .......... pre_synth.tcl
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
# Date .......... 02 Oct 2022
# Version ....... 2.0
# Description ...
#   Script to read product/project information from a text file, obtain GIT
# repository information and set the generics/parameters on the top level
# module.
#
.
wq
END

#### 0019 - Part 16b ###########################################################

ed 0019/common/other/src/script/petalinux-build-id.sh <<END
3,13d
.
2a
#
# File .......... petalinux-build-id.sh
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Common (SpaceWire UK Tutorial)
# Date .......... 02 Oct 2022
# Version ....... 1.0
# Description ...
#   Script to read project information file, obtain GIT repository information,
# append project information file with GIT information, build PetaLinux project
# and then restore project information file.
#
.
wq
END

#### 0020 - Part 16c ###########################################################

ed 0020/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi <<END
2a
#
# File .......... index.cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 02 Oct 2022
# Version ....... 7.0
# Description ...
#   Dynamic (server & client side) webpage to display system information from
# PetaLinux running on the Zedboard. Already includes a widget that displays the
# uptime of PetaLinux and widgets to read & write register functionality. Also
# uses a style sheet for a more improved look. Enhanced the peek & poke
# capabilities such that multiple registers can be accessed. Added in global
# controls for the multiple registers and also file access so the register
# configuration can be saved and re-loaded. Added a Product Information
# section for the Firmware & the Operating System.
#

.
wq
END

ed 0020/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 02 Oct 2022
// Version ....... 5.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly. Enhanced functions to improve
// webpage look & feel, including the use of new status animation images for
// success/fail of register read/write calls and also a register configuration
// save & re-load facility. Added the functions required to support reading
// strings from the PL address space and dynamically updating the the webpage
// accordingly. Now displays the GIT Hash in the Firmware Information section &
// supports the displaying of a whole new PetaLinux Information section.
//

.
wq
END

ed 0020/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 02 Oct 2022
# Version ....... 6.0
# Description ...
#   Application recipe for a dynamic (server & client side) webpage that consists
# of a webpage (cgi), uptime script (cgi), support functions (js), styles (css),
# an image of the Zedboard (png), 3 status animation images (gif) & a project
# information file (txt).
#

.
wq
END

#### 0021 - Part 16d ###########################################################

#### 0022 - Part 17a ###########################################################

ed 0022/zedboard_leds_switches/fw/src/constraint/zedboard.xdc <<END
0a
#
# File .......... zedboard.xdc
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
# Date .......... 29 Oct 2022
# Version ....... 2.0
# Description ...
#   Pin & timing constraints for the Zedboard LEDs & Switches design. Now includes
# constraints for the Buttons.
#

.
wq
END

ed 0022/zedboard_leds_switches/fw/src/design/axi_gpio_zed.v <<END
1,13d
.
0a
//
// File .......... axi_gpio_zed.v
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2022
// Version ....... 1.0
// Description ...
//   AXI4-Lite controlled GPIO block written in basic Verilog. Primary purpose
// is to provide access to the LEDs, Switches & Push Buttons of the Zedboard.
// Design offers an Interrupt that can be thrown when any of the Push Buttons
// are pressed or released. Address map is compatible with the one used in the
// AXI GPIO IP from Xilinx, albeit a cut-down version.
//
.
wq
END

ed 0022/zedboard_leds_switches/fw/src/design/axi_register_bank.v <<END
1,25d
.
0a
//
// File .......... axi_register_bank.v
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2022
// Version ....... 1.0
// Description ...
//   AXI4-Lite controlled general purpose register bank written in basic
// Verilog. This module is intended to be a building block for something more
// useful.
//
// With c_data_w = 32 the number of registers is as follows :-
//
// c_addr_w - c_registers
// ~~~~~~~~ - ~~~~~~~~~~~
// 2        -   1
// 3        -   2
// 4        -   4
// 5        -   8
// 6        -  16
// 7        -  32
// 8        -  64
// 9        - 128
// 10       - 256
//
.
wq
END

ed 0022/zedboard_leds_switches/fw/src/design/debounce.v <<END
1,9d
.
0a
//
// File .......... debounce.v
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2022
// Version ....... 1.0
// Description ...
//   Simple switch debouncer.
//
.
wq
END

ed 0022/zedboard_leds_switches/fw/src/diagram/system/hdl/system_wrapper.sv <<END
1,9d
.
0a
//
// File .......... system_wrapper.sv
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard LEDs & Switches (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2022
// Version ....... 3.0
// Description ...
//   Top level wrapper for the underlying block design.
//
.
wq
END

#### 0023 - Part 17b ###########################################################

ed 0023/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/axi-gpio-zed-test/files/axi-gpio-zed-test.c <<END
1,9d
.
0a
//
// File .......... axi-gpio-zed-test.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 29 Oct 2022
// Version ....... 1.0
// Description ...
//   Very simple program to access a GPIO device using the User Space I/O
// subsystem. Demonstrates a blocking wait on interrupt routine.
//
.
wq
END

ed 0023/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/led-runner/files/led-runner <<END
2a
#
# File .......... led-runner
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 29 Oct 2022
# Version ....... 2.0
# Description ...
#   Expanding & contracting LED sequence using the GPIO located at 0x4001_0000.
#

.
wq
END

ed 0023/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi <<END
0a
/*
 * File .......... system-user.dtsi
 * Author ........ Steve Haywood
 * Website ....... http://www.spacewire.co.uk
 * Project ....... Zedboard Linux (SpaceWire UK Tutorial)
 * Date .......... 29 Oct 2022
 * Version ....... 2.0
 * History .......
 *   1.0 TEMPLATE
 * Description ...
 *   Added User Space I/O (UIO) for the AXI GPIO Zed module.
 */

.
wq
END

#### 0024 - Part 18 ############################################################

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/conf/petalinuxbsp.conf <<END
0a
#
# File .......... petalinuxbsp.conf
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 03 Aug 2023
# Version ....... 2.0
# Description ...
#   Updated to install the following :-
# -- ntp ....... Network Time Protocol
# -- ntpdate ... Set the date and time via NTP
# -- ntpq ...... Standard NTP query program
# -- sntp ...... Simple Network Time Protocol
# -- nano ...... Text editor
# Updated to install a LAMP style stack :-
# -- Apache .... HTTP server
# -- SQLite .... SQL database engine
# -- PHP ....... Scripting language
#

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/peekpokecgi.bb <<END
1,5d
.
0a
#
# File .......... peekpokecgi.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 03 Aug 2023
# Version ....... 3.0
# Description ...
#   Application recipe for the peek, poke & peekstring CGI binaries. Forced
# run-as-root privileges set.
#

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/hello_world.php <<END
0a
<?php
//
// File .......... hello_world.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 1.0
// Description ...
//   Simple hello world in PHP.
//
?>

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.php <<END
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 8.0
// History .......
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi
// Description ...
//   Dynamic (server & client side) webpage to display system information from
// PetaLinux running on the Zedboard. Already includes a widget that displays the
// uptime of PetaLinux and widgets to read & write register functionality. Also
// uses a style sheet for a more improved look. Enhanced the peek & poke
// capabilities such that multiple registers can be accessed. Added in global
// controls for the multiple registers and also file access so the register
// configuration can be saved and re-loaded. Added a Product Information
// section for the Firmware & the Operating System. This source is a direct
// conversion from the previous CGI (shell script).
//
?>

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/phpliteadmin.config.php <<END
0a
<?php
//
// File .......... phpliteadmin.config.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 1.0
// History .......
//   0.0 TEMPLATE
// Description ...
//   PHPLite configuration with the database location changed from . to db.
//
?>

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/sqlite_test.php <<END
1,16d
.
0a
<?php
//
// File .......... sqlite_test.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 1.0
// Description ...
//   Simple HTML, PHP & SQLite example code that checks the basic operation of
// SQLite. SQL queries used are :-
//
// 1. Create/open database
// 1. Create table
// 3. Insert row
// 4. Close database
//
?>
.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/test-cgi <<END
2a
#
# File .......... test-cgi
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 03 Aug 2023
# Version ....... 1.0
# Description ...
#   Stock test script (now enabled to run).
#

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/index.html <<END
0a
<!--
// File .......... index.html
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 2.0
// Description ...
//   Simple index page for accessing all the other pages.
-->

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 03 Aug 2023
// Version ....... 6.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly. Enhanced functions to improve
// webpage look & feel, including the use of new status animation images for
// success/fail of register read/write calls and also a register configuration
// save & re-load facility. Added the functions required to support reading
// strings from the PL address space and dynamically updating the the webpage
// accordingly. Now displays the GIT Hash in the Firmware Information section &
// supports the displaying of a whole new PetaLinux Information section. Added
// backslash to uptime CGI call.
//

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 03 Aug 2023
# Version ....... 7.0
# Description ...
#   Application recipe for a dynamic (server & client side) webpage that consists
# of a webpage (php), uptime script (cgi), support functions (js), styles (css),
# an image of the Zedboard (png), 3 status animation images (gif) & a project
# information file (txt). The move to a LAMP style stack introduces new PHP
# files (index, hello_world, sqlite_test & phpliteadmin).
#

.
wq
END

ed 0024/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-httpd/apache2/apache2_%.bbappend <<END
0a
#
# File .......... apache2_%.bbappend
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 03 Aug 2023
# Version ....... 1.0
# Description ...
#   Modify Apache 2 recipe to suite PetaLinux.
#

.
wq
END

#### 0025 - Part 19 ############################################################

ed 0025/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/Makefile <<END
0a
#
# File .......... Makefile
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 09 Feb 2024
# Version ....... 3.0
# Description ...
#   Makefile for the peek, poke, peekstring & loadfirmware CGI binaries.
#

.
wq
END

ed 0025/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/loadfirmware.c <<END
1,11d
.
0a
//
// File .......... loadfirmware.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 09 Feb 2024
// Version ....... 1.0
// Description ...
//   Very simple CGI to load PL bitstream.
//
.
wq
END

ed 0025/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/peekpokecgi.bb <<END
1,5d
.
0a
#
# File .......... peekpokecgi.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 09 Feb 2024
# Version ....... 4.0
# Description ...
#   Application recipe for the peek, poke, peekstring & loadfirmware CGI binaries.
# Forced run-as-root privileges set.
#

.
wq
END

ed 0025/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.php <<END
1,11d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 09 Feb 2024
// Version ....... 9.0
// History .......
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi
// Description ...
//   Dynamic (server & client side) webpage to display system information from
// PetaLinux running on the Zedboard. Already includes a widget that displays the
// uptime of PetaLinux and widgets to read & write register functionality. Also
// uses a style sheet for a more improved look. Enhanced the peek & poke
// capabilities such that multiple registers can be accessed. Added in global
// controls for the multiple registers and also file access so the register
// configuration can be saved and re-loaded. Added a Product Information
// section for the Firmware & the Operating System. This source is a direct
// conversion from the previous CGI (shell script). Now includes a table that
// displays the loadable firmware images available on the SD Card.
//
?>
.
wq
END

ed 0025/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js <<END
1,11d
.
0a
//
// File .......... uptime.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 09 Feb 2024
// Version ....... 7.0
// Description ...
//   Uptime support functions for the dynamic (client side) webpage. Updated to
// add read and write register requests that call the peek & poke CGI scripts
// and update the client side webpage accordingly. Enhanced functions to improve
// webpage look & feel, including the use of new status animation images for
// success/fail of register read/write calls and also a register configuration
// save & re-load facility. Added the functions required to support reading
// strings from the PL address space and dynamically updating the the webpage
// accordingly. Now displays the GIT Hash in the Firmware Information section &
// supports the displaying of a whole new PetaLinux Information section. Added
// backslash to uptime CGI call. Now includes support for loadable firmware
// images.
//
.
wq
END

#### 0026 - Part 20 ############################################################

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/Makefile <<END
0a
#
# File .......... Makefile
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 27 Feb 2024
# Version ....... 4.0
# Description ...
#   Makefile for the peek, poke, peekstring, loadfirmware & bitbash CGI binaries.
#

.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/bitbash.c <<END
1,17d
.
0a
//
// File .......... bitbash.c
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 28 Feb 2024
// Version ....... 2.0
// History .......
//   1.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/peek.c
//  +1.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/files/poke.c
// Description ...
//   Very simple CGI application for peeking, poking and general bit bashing
// of a single 32-bit address location. Provides read back value or an error
// message to the client side application.
//
// Examples :-
//   http://192.168.2.87/cgi-bin/bitbash?peek&0x40010000 ......... Peek value @ 0x40010000
//   http://192.168.2.87/cgi-bin/bitbash?poke&0x40010000&0xF ..... Poke 0xF @ 0x40010000
//   http://192.168.2.87/cgi-bin/bitbash?set&0x40010000&0x81 ..... Set bits 0 & 7 @ 0x40010000
//   http://192.168.2.87/cgi-bin/bitbash?clear&0x40010000&0x2 .... Clear bit 1 @ 0x40010000
//   http://192.168.2.87/cgi-bin/bitbash?toggle&0x40010000&0xC ... Toggle bits 2 & 3 @ 0x40010000
//
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/peekpokecgi/peekpokecgi.bb <<END
1,5d
.
0a
#
# File .......... peekpokecgi.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 27 Feb 2024
# Version ....... 5.0
# Description ...
#   Application recipe for the peek, poke, peekstring, loadfirmware & bitbash CGI
# binaries.
#

.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/phpliteadmin.config.php <<END
0a
<?php
//
// File .......... phpliteadmin.config.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 2.0
// History .......
//   0.0 TEMPLATE
// Description ...
//   PHPLite configuration with the database location changed to be a directory on the
// Zedboard SD-Card.
//
?>

.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/sqlite_test.php <<END
1,23d
.
0a
<?php
//
// File .......... sqlite_test.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 2.0
// Description ...
//   Simple HTML, PHP & SQLite example code that offers some degree of error
// checking on the form inputs. Reports SQL operations and success/failure
// status. Demonstrates some of the common SQL queries :-
//
// 1. Create/open database
// 2. Create table
// 3. Drop table
// 4. Insert row
// 5. Delete row
// 6. Update row
// 7. Close database
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/home/index.php <<END
1,13d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 1.0
// Description ...
//   Webpage for Home.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/index.php <<END
1,13d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 1.0
// Description ...
//   Forwarder page for use in root www directory.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/peekpoke/index.php <<END
1,13d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 10.0
// History .......
//   9.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.php
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi
// Description ...
//   Webpage for Peek & Poke Addresses.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/peekpoke/script.js <<END
1,11d
.
0a
//
// File .......... script.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 8.0
// History .......
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js
// Description ...
//   Javascript for Peek & Poke Addresses.
//
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/share/footer.php <<END
1,13d
.
0a
<?php
//
// File .......... footer.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 1.0
// Description ...
//   Footer include for website pages.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/share/header.php <<END
1,13d
.
0a
<?php
//
// File .......... header.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 1.0
// Description ...
//   Header include for website pages.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/share/script.js <<END
1,11d
.
0a
//
// File .......... script.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 28 Feb 2024
// Version ....... 1.0
// Description ...
//   Global Javascript for use in all webpages.
//
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/share/style.css <<END
1,11d
.
0a
/*
 * File .......... style.css
 * Author ........ Steve Haywood
 * Website ....... http://www.spacewire.co.uk
 * Project ....... Zedboard Linux (SpaceWire UK Tutorial)
 * Date .......... 27 Feb 2024
 * Version ....... 2.0
 * History .......
 *   1.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/styles.css
 * Description ...
 *   Global Cascading Style Sheet for use in all webpages.
 */
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/system/index.php <<END
1,11d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 10.0
// History .......
//   9.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.php
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/cgi-bin/index.cgi
// Description ...
//   Webpage for System Information & Firmware Load.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/system/script.js <<END
1,11d
.
0a
//
// File .......... script.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 27 Feb 2024
// Version ....... 8.0
// History .......
//   7.0 zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/uptime.js
// Description ...
//   Javascript for System Information & Firmware Load.
//
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/zedboard/index.php <<END
1,15d
.
0a
<?php
//
// File .......... index.php
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 26 Feb 2024
// Version ....... 1.0
// Description ...
//   Webpage for Interactive Zedboard.
//
?>
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/zedboard/script.js <<END
1,11d
.
0a
//
// File .......... script.js
// Author ........ Steve Haywood
// Website ....... http://www.spacewire.co.uk
// Project ....... Zedboard Linux (SpaceWire UK Tutorial)
// Date .......... 28 Feb 2024
// Version ....... 1.0
// Description ...
//   Javascript for Interactive Zedboard.
//
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/files/zedboard/style.css <<END
1,11d
.
0a
/*
 * File .......... style.css
 * Author ........ Steve Haywood
 * Website ....... http://www.spacewire.co.uk
 * Project ....... Zedboard Linux (SpaceWire UK Tutorial)
 * Date .......... 28 Feb 2024
 * Version ....... 1.0
 * Description ...
 *   Cascading Style Sheet for Interactive Zedboard.
 */
.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-apps/website/website.bb <<END
1,4d
.
0a
#
# File .......... website.bb
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 27 Feb 2024
# Version ....... 8.0
# Description ...
#   Application recipe for a dynamic (server & client side) website that is split
# into separate sections (directories). Each section contains an index page
# along with any associated files (sub-pages, scripts, styles, images, etc.).
# There are also two shared areas for common files.
#

.
wq
END

ed 0026/zedboard_linux/os/petalinux/project-spec/meta-user/recipes-httpd/apache2/apache2_%.bbappend <<END
0a
#
# File .......... apache2_%.bbappend
# Author ........ Steve Haywood
# Website ....... http://www.spacewire.co.uk
# Project ....... Zedboard Linux (SpaceWire UK Tutorial)
# Date .......... 27 Feb 2024
# Version ....... 2.0
# Description ...
#   Modified Apache 2 recipe to suite PetaLinux. Updated to allow Apache to run as
# root instead of deamon.
#

.
wq
END
}


################################################################################
# Check if an argument option is set.
# Arguments ...... $1 ... Str: Option
# Return ......... Set (0=unset, 1=set)
# Shared (In) .... argv
# Shared (Out) ... None
option_set()
{
  [[ " ${argv[*]} " =~ " ${1} " ]] && echo 1 || echo 0
}


################################################################################
# Main function.
# Arguments ...... None
# Return ......... None
# Shared (In) .... argv
# Shared (Out) ... argv
main()
{
  # Declare local constants
  local -r  opthelp="--help"  # Str: Help option name
  local -Ar options=(         # ARR: Options & associated help information
    [${opthelp}]="Display this help and exit."
  )
  local -ar optorder=(        # Arr: Help options display order
    ${opthelp}
  )

  # Declare local variables
  local     arg               # Str: Current argument from argv array
  local     project=""        # Str: Project directory [arg] (mandatory)
  local     option            # Str: Current option from optorder array

  # Display help information
  if (($(option_set ${opthelp}))); then
    echo "Usage: $(basename ${0}) PROJECT-DIRECTORY... [OPTION]..."
    echo "Edit headers in the source files in PROJECT-DIRECTORY. Core function is the output from swuk_repos_gen_fix_headers."
    echo
    for option in ${optorder[@]}
    do
      echo "      ${option} $(printf ' %.0s' {1..12} | head -c $((12-${#option}))) ${options[${option}]}"
    done
    echo
    exit 0
  fi

  # Get & check the arguments
  for arg in ${argv[@]}; do
    if [[ ${arg:0:2} == "--" ]]; then  # Option
      [[ ! -v options[${arg}] ]] && echo "Option (${arg}) is not recognised!" && exit 1
    elif [[ -z ${project} ]]; then  # Project directory
      project=${arg}
      [[ ! -d ${project} ]] && echo "Project directory (${arg}) does not exist!" && exit 1
    else
      echo "Unexpected argument (${arg}) found!" && exit 1
      exit 1
    fi
  done

  # Further check the arguments
  [[ -z ${project} ]] && echo "No project directory specified!" && exit 1

  # Move into project directory
  cd ${project}

  # Edit the headers
  edit_headers

  # Move out of project directory
  cd ..
}


################################################################################
# Opening gambit.
# Arguments ...... None
# Return ......... None
# Exit code ...... Status (0=success, 1=failure)
# Shared (In) .... $#, $@
# Shared (Out) ... argc, argv
declare -ri argc=${#}    # Int: Get argument count
declare -ra argv=(${@})  # Arr: Get argument values (space-separated) into array
main
exit 0
