From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 13 02:35:29 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AA658F54 for ; Wed, 13 Nov 2013 02:35:29 +0000 (UTC) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 9444F2B73 for ; Wed, 13 Nov 2013 02:35:29 +0000 (UTC) Received: from Alfreds-MacBook-Air.local (c-76-21-10-192.hsd1.ca.comcast.net [76.21.10.192]) by elvis.mu.org (Postfix) with ESMTPSA id 0B40D1A3C6D; Tue, 12 Nov 2013 18:35:28 -0800 (PST) Message-ID: <5282E56F.4020307@freebsd.org> Date: Tue, 12 Nov 2013 18:35:27 -0800 From: Alfred Perlstein Organization: FreeBSD User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: "Teske, Devin" , FreeBSD Hackers Subject: Loader forth changes for customization Content-Type: multipart/mixed; boundary="------------070004070708090008010005" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2013 02:35:29 -0000 This is a multi-part message in MIME format. --------------070004070708090008010005 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hey folks, I added some forth using Devin's help to make it easier to customize the FreeBSD boot loader graphics. Diffs are here: https://github.com/alfredperlstein/freebsd/compare/loader_custom_rc -or- https://github.com/alfredperlstein/freebsd/compare/loader_custom_rc.diff Diff attached. Also attached is a custom loader.rc file and loader.conf file that shows how to set the brand/logo. Please review. -Alfred --------------070004070708090008010005 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="loader_custom_rc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="loader_custom_rc.diff" diff --git a/sys/boot/forth/beastie.4th b/sys/boot/forth/beastie.4th index 4a107af..5c5a209 100644 --- a/sys/boot/forth/beastie.4th +++ b/sys/boot/forth/beastie.4th @@ -251,6 +251,15 @@ variable logoY 2drop exit then + \ if it refers to a raw symbol then run that function + sfind if + logoX @ logoY @ + 2 roll + execute + else + drop + then + 2drop ; diff --git a/sys/boot/forth/brand.4th b/sys/boot/forth/brand.4th index b6f22c8..3230953 100644 --- a/sys/boot/forth/brand.4th +++ b/sys/boot/forth/brand.4th @@ -87,5 +87,14 @@ variable brandY 2drop exit then + \ if it refers to a raw symbol then run that function + sfind if + brandX @ brandY @ + 2 roll + execute + else + drop + then + 2drop ; diff --git a/sys/boot/forth/loader.rc b/sys/boot/forth/loader.rc index a84753d..86ad695e 100644 --- a/sys/boot/forth/loader.rc +++ b/sys/boot/forth/loader.rc @@ -8,6 +8,11 @@ include /boot/loader.4th \ NOTE: Change to `initialize' if you enable the below boot menu start +\ Load in any local forth files +only forth also support-functions +s" /boot/loader.rc.local" source-if-exists +only forth also + \ Tests for password -- executes autoboot first if a password was defined check-password diff --git a/sys/boot/forth/support.4th b/sys/boot/forth/support.4th index 645e14d..c4f96b5 100644 --- a/sys/boot/forth/support.4th +++ b/sys/boot/forth/support.4th @@ -861,6 +861,40 @@ only forth also support-functions definitions throw ; +\ Does the file exist? +: file-exists? ( c-addr/u -- bool ) + O_RDONLY fopen \ open file + dup \ save a copy to not leak + -1 <> if + fclose true + else + drop false + then +; + +\ Source file as code if it exists. +: source-if-exists ( c-addr/u -- ) + + 2dup file-exists? if + \ If file exists then prepend "include" to it + + \ first allocate a string, top of stack is strlen of + \ the filename, so just add a comfortable 15 bytes to it. + dup 15 + + allocate if ENOMEM throw then + 0 + + s" include " strcat + \ grab the original string up so we can strcat + 3 roll 3 roll + strcat + + \ evaluate " include file" + 2dup evaluate + drop free + then +; + : print_line line_buffer strtype cr ; : print_syntax_error --------------070004070708090008010005 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="loader.rc.local" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="loader.rc.local" : truenas-logo ( x y -- ) \ "TrueNAS" logo in B/W (13 rows x 21 columns) 5 + swap 6 + swap 2dup at-xy ." ______" 1+ 2dup at-xy ." |__ ___| __ _ _ ___ " 1+ 2dup at-xy ." | | | '__|| | |/ _ \" 1+ 2dup at-xy ." | | | | | | | / __/" 1+ 2dup at-xy ." | | | | | |_| | |" 1+ 2dup at-xy ." |_| |_| |_____|\___|" 1+ 2dup at-xy ." _ _ __ _____" 1+ 2dup at-xy ." | \ | | / \ / ___|" 1+ 2dup at-xy ." | \ | |/ /\ \| (__" 1+ 2dup at-xy ." | |\\ | | |__| |\___ \" 1+ 2dup at-xy ." | | \\| | __ |____) |" 1+ 2dup at-xy ." | | \ | | | | |" 1+ at-xy ." |_| \_|_| |_|_____/" \ Put the cursor back at the bottom 0 25 at-xy ; : truenas-brand ( x y -- ) \ "Brand" [wide] logo in B/W (7 rows x 42 columns) 2dup at-xy ." ______ _ _ __ _____ " 1+ 2dup at-xy ." |__ ___| | \ | | / \ / ___|" 1+ 2dup at-xy ." | | ____ _ __ ___| \ | |/ /\ \| (__" 1+ 2dup at-xy ." | || '__|| | |/ _ \ |\\ | | |__| |\___ \" 1+ 2dup at-xy ." | || | | | | / __/ | \\| | __ |____) |" 1+ 2dup at-xy ." | || | | |_| | | | \ | | | | |" 1+ at-xy ." |_||_| |_____|\___|_| \_|_| |_|_____/" \ Put the cursor back at the bottom 0 25 at-xy ; --------------070004070708090008010005 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="loader.conf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="loader.conf" loader_logo="truenas-logo" loader_menu_title="Welcome to TrueNAS" loader_brand="truenas-brand" --------------070004070708090008010005--