config.y revision 20457
1249259Sdim%union { 2249259Sdim char *str; 3249259Sdim int val; 4249259Sdim struct file_list *file; 5249259Sdim struct idlst *lst; 6249259Sdim} 7249259Sdim 8249259Sdim%token AND 9249259Sdim%token ANY 10249259Sdim%token ARGS 11249259Sdim%token AT 12263508Sdim%token AUTO 13249259Sdim%token BIO 14249259Sdim%token BUS 15249259Sdim%token COMMA 16249259Sdim%token CONFIG 17249259Sdim%token CONFLICTS 18249259Sdim%token CONTROLLER 19249259Sdim%token CPU 20249259Sdim%token CSR 21249259Sdim%token DEVICE 22249259Sdim%token DISABLE 23249259Sdim%token DISK 24249259Sdim%token DRIVE 25249259Sdim%token DRQ 26249259Sdim%token DUMPS 27249259Sdim%token EQUALS 28263508Sdim%token FLAGS 29263508Sdim%token IDENT 30249259Sdim%token INTERLEAVE 31249259Sdim%token IOMEM 32263508Sdim%token IOSIZ 33249259Sdim%token IRQ 34249259Sdim%token MACHINE 35263508Sdim%token MAJOR 36249259Sdim%token MASTER 37249259Sdim%token MAXUSERS 38263508Sdim%token MINOR 39263508Sdim%token MINUS 40249259Sdim%token NET 41263508Sdim%token NEXUS 42249259Sdim%token NONE 43249259Sdim%token ON 44249259Sdim%token OPTIONS 45263508Sdim%token MAKEOPTIONS 46263508Sdim%token PORT 47249259Sdim%token PRIORITY 48249259Sdim%token PSEUDO_DEVICE 49249259Sdim%token ROOT 50263508Sdim%token SEMICOLON 51263508Sdim%token SEQUENTIAL 52263508Sdim%token SIZE 53263508Sdim%token SLAVE 54263508Sdim%token SWAP 55263508Sdim%token TARGET 56263508Sdim%token TTY 57263508Sdim%token TRACE 58263508Sdim%token UNIT 59263508Sdim%token VECTOR 60263508Sdim 61263508Sdim%token <str> ID 62263508Sdim%token <val> NUMBER 63263508Sdim%token <val> FPNUMBER 64263508Sdim 65263508Sdim%type <str> Save_id 66263508Sdim%type <str> Opt_value 67263508Sdim%type <str> Dev 68263508Sdim%type <lst> Id_list 69263508Sdim%type <val> optional_size 70263508Sdim%type <val> optional_sflag 71263508Sdim%type <str> device_name 72263508Sdim%type <val> major_minor 73263508Sdim%type <val> arg_device_spec 74263508Sdim%type <val> root_device_spec root_device_specs 75263508Sdim%type <val> dump_device_spec 76263508Sdim%type <file> swap_device_spec 77263508Sdim%type <file> comp_device_spec 78263508Sdim 79263508Sdim%{ 80263508Sdim 81249259Sdim/* 82263508Sdim * Copyright (c) 1988, 1993 83263508Sdim * The Regents of the University of California. All rights reserved. 84249259Sdim * 85249259Sdim * Redistribution and use in source and binary forms, with or without 86249259Sdim * modification, are permitted provided that the following conditions 87263508Sdim * are met: 88263508Sdim * 1. Redistributions of source code must retain the above copyright 89263508Sdim * notice, this list of conditions and the following disclaimer. 90263508Sdim * 2. Redistributions in binary form must reproduce the above copyright 91263508Sdim * notice, this list of conditions and the following disclaimer in the 92263508Sdim * documentation and/or other materials provided with the distribution. 93263508Sdim * 3. All advertising materials mentioning features or use of this software 94263508Sdim * must display the following acknowledgement: 95263508Sdim * This product includes software developed by the University of 96263508Sdim * California, Berkeley and its contributors. 97263508Sdim * 4. Neither the name of the University nor the names of its contributors 98263508Sdim * may be used to endorse or promote products derived from this software 99249259Sdim * without specific prior written permission. 100249259Sdim * 101263508Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 102263508Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 103263508Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 104263508Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 105263508Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 106263508Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 107263508Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 108263508Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 109263508Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 110263508Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 111263508Sdim * SUCH DAMAGE. 112263508Sdim * 113263508Sdim * @(#)config.y 8.1 (Berkeley) 6/6/93 114263508Sdim */ 115263508Sdim 116263508Sdim#include "config.h" 117263508Sdim 118263508Sdim#include <sys/disklabel.h> 119263508Sdim#include <sys/diskslice.h> 120263508Sdim 121263508Sdim#include <ctype.h> 122263508Sdim#include <stdio.h> 123263508Sdim#include <err.h> 124263508Sdim#include <string.h> 125263508Sdim 126263508Sdimstruct device cur; 127263508Sdimstruct device *curp = 0; 128263508Sdimchar *temp_id; 129263508Sdimchar *val_id; 130263508Sdim 131263508Sdim%} 132263508Sdim%% 133263508SdimConfiguration: 134263508Sdim Many_specs 135263508Sdim = { verifysystemspecs(); } 136263508Sdim ; 137263508Sdim 138263508SdimMany_specs: 139263508Sdim Many_specs Spec 140263508Sdim | 141263508Sdim /* lambda */ 142263508Sdim ; 143263508Sdim 144263508SdimSpec: 145263508Sdim Device_spec SEMICOLON 146263508Sdim = { newdev(&cur); } | 147263508Sdim Config_spec SEMICOLON 148263508Sdim | 149263508Sdim TRACE SEMICOLON 150263508Sdim = { do_trace = !do_trace; } | 151263508Sdim SEMICOLON 152263508Sdim | 153263508Sdim error SEMICOLON 154263508Sdim ; 155263508Sdim 156263508SdimConfig_spec: 157263508Sdim MACHINE Save_id 158263508Sdim = { 159263508Sdim if (!strcmp($2, "vax")) { 160263508Sdim machine = MACHINE_VAX; 161263508Sdim machinename = "vax"; 162263508Sdim } else if (!strcmp($2, "tahoe")) { 163263508Sdim machine = MACHINE_TAHOE; 164263508Sdim machinename = "tahoe"; 165263508Sdim } else if (!strcmp($2, "hp300")) { 166263508Sdim machine = MACHINE_HP300; 167263508Sdim machinename = "hp300"; 168263508Sdim } else if (!strcmp($2, "i386")) { 169263508Sdim machine = MACHINE_I386; 170263508Sdim machinename = "i386"; 171263508Sdim } else if (!strcmp($2, "mips")) { 172263508Sdim machine = MACHINE_MIPS; 173263508Sdim machinename = "mips"; 174263508Sdim } else if (!strcmp($2, "pmax")) { 175263508Sdim machine = MACHINE_PMAX; 176263508Sdim machinename = "pmax"; 177263508Sdim } else if (!strcmp($2, "luna68k")) { 178263508Sdim machine = MACHINE_LUNA68K; 179263508Sdim machinename = "luna68k"; 180263508Sdim } else if (!strcmp($2, "news3400")) { 181263508Sdim machine = MACHINE_NEWS3400; 182263508Sdim machinename = "news3400"; 183263508Sdim } else 184263508Sdim yyerror("Unknown machine type"); 185263508Sdim } | 186263508Sdim CPU Save_id 187263508Sdim = { 188263508Sdim struct cputype *cp = 189263508Sdim (struct cputype *)malloc(sizeof (struct cputype)); 190263508Sdim memset(cp, 0, sizeof(*cp)); 191263508Sdim cp->cpu_name = ns($2); 192263508Sdim cp->cpu_next = cputype; 193263508Sdim cputype = cp; 194263508Sdim free(temp_id); 195263508Sdim } | 196263508Sdim OPTIONS Opt_list 197263508Sdim | 198263508Sdim MAKEOPTIONS Mkopt_list 199263508Sdim | 200263508Sdim IDENT ID 201263508Sdim = { ident = ns($2); } | 202263508Sdim System_spec 203263508Sdim | 204263508Sdim MAXUSERS NUMBER 205263508Sdim = { maxusers = $2; }; 206263508Sdim 207263508SdimSystem_spec: 208263508Sdim System_id System_parameter_list 209263508Sdim = { checksystemspec(*confp); } 210263508Sdim ; 211263508Sdim 212263508SdimSystem_id: 213263508Sdim CONFIG Save_id 214263508Sdim = { mkconf($2); } 215263508Sdim ; 216263508Sdim 217263508SdimSystem_parameter_list: 218263508Sdim System_parameter_list System_parameter 219263508Sdim | System_parameter 220263508Sdim ; 221263508Sdim 222263508SdimSystem_parameter: 223263508Sdim addr_spec 224263508Sdim | swap_spec 225263508Sdim | root_spec 226263508Sdim | dump_spec 227263508Sdim | arg_spec 228263508Sdim ; 229263508Sdim 230263508Sdimaddr_spec: 231263508Sdim AT NUMBER 232263508Sdim = { loadaddress = $2; } 233263508Sdim ; 234263508Sdim 235263508Sdimswap_spec: 236263508Sdim SWAP optional_on swap_device_list 237263508Sdim ; 238263508Sdim 239263508Sdimswap_device_list: 240263508Sdim swap_device_list AND swap_device 241263508Sdim | swap_device 242263508Sdim ; 243263508Sdim 244263508Sdimswap_device: 245263508Sdim swap_device_spec optional_size optional_sflag 246263508Sdim = { mkswap(*confp, $1, $2, $3); } 247263508Sdim ; 248263508Sdim 249263508Sdimswap_device_spec: 250263508Sdim device_name 251263508Sdim = { 252263508Sdim struct file_list *fl = newflist(SWAPSPEC); 253263508Sdim 254263508Sdim if (eq($1, "generic")) 255263508Sdim fl->f_fn = $1; 256263508Sdim else { 257263508Sdim fl->f_swapdev = nametodev($1, 0, 258249259Sdim COMPATIBILITY_SLICE, 'b'); 259249259Sdim fl->f_fn = devtoname(fl->f_swapdev); 260249259Sdim } 261249259Sdim $$ = fl; 262249259Sdim } 263263508Sdim | major_minor 264263508Sdim = { 265263508Sdim struct file_list *fl = newflist(SWAPSPEC); 266249259Sdim 267249259Sdim fl->f_swapdev = $1; 268249259Sdim fl->f_fn = devtoname($1); 269249259Sdim $$ = fl; 270249259Sdim } 271249259Sdim ; 272249259Sdim 273263508Sdimroot_spec: 274263508Sdim ROOT optional_on root_device_specs 275263508Sdim = { 276263508Sdim struct file_list *fl = *confp; 277263508Sdim 278263508Sdim if (fl && fl->f_rootdev != NODEV) 279263508Sdim yyerror("extraneous root device specification"); 280263508Sdim else 281249259Sdim fl->f_rootdev = $3; 282263508Sdim } 283263508Sdim ; 284263508Sdim 285263508Sdimroot_device_specs: 286249259Sdim root_device_spec AND root_device_specs 287263508Sdim = { 288263508Sdim warnx("extraneous root devices ignored"); 289249259Sdim $$ = $1; 290263508Sdim } 291263508Sdim | root_device_spec 292263508Sdim ; 293263508Sdim 294263508Sdimroot_device_spec: 295263508Sdim device_name 296263508Sdim = { $$ = nametodev($1, 0, COMPATIBILITY_SLICE, 'a'); } 297263508Sdim | major_minor 298263508Sdim ; 299263508Sdim 300263508Sdimdump_spec: 301263508Sdim DUMPS optional_on dump_device_spec 302263508Sdim = { 303263508Sdim struct file_list *fl = *confp; 304263508Sdim 305263508Sdim if (fl && fl->f_dumpdev != NODEV) 306263508Sdim yyerror("extraneous dump device specification"); 307263508Sdim else 308263508Sdim fl->f_dumpdev = $3; 309263508Sdim } 310263508Sdim 311263508Sdim ; 312263508Sdim 313263508Sdimdump_device_spec: 314263508Sdim device_name 315263508Sdim = { $$ = nametodev($1, 0, COMPATIBILITY_SLICE, 'b'); } 316263508Sdim | major_minor 317263508Sdim ; 318249259Sdim 319249259Sdimarg_spec: 320249259Sdim ARGS optional_on arg_device_spec 321249259Sdim = { yyerror("arg device specification obsolete, ignored"); } 322249259Sdim ; 323263508Sdim 324263508Sdimarg_device_spec: 325263508Sdim device_name 326263508Sdim = { $$ = nametodev($1, 0, COMPATIBILITY_SLICE, 'b'); } 327263508Sdim | major_minor 328263508Sdim ; 329263508Sdim 330263508Sdimmajor_minor: 331263508Sdim MAJOR NUMBER MINOR NUMBER 332263508Sdim = { $$ = makedev($2, $4); } 333263508Sdim ; 334263508Sdim 335263508Sdimoptional_on: 336263508Sdim ON 337263508Sdim | /* empty */ 338263508Sdim ; 339263508Sdim 340263508Sdimoptional_size: 341263508Sdim SIZE NUMBER 342263508Sdim = { $$ = $2; } 343263508Sdim | /* empty */ 344263508Sdim = { $$ = 0; } 345263508Sdim ; 346263508Sdim 347249259Sdimoptional_sflag: 348249259Sdim SEQUENTIAL 349249259Sdim = { $$ = 2; } 350249259Sdim | /* empty */ 351249259Sdim = { $$ = 0; } 352249259Sdim ; 353263508Sdim 354251662Sdimdevice_name: 355251662Sdim Save_id 356263508Sdim = { $$ = $1; } 357263508Sdim | Save_id NUMBER 358263508Sdim = { 359263508Sdim char buf[80]; 360263508Sdim 361263508Sdim (void) snprintf(buf, 80, "%s%d", $1, $2); 362263508Sdim $$ = ns(buf); free($1); 363263508Sdim } 364263508Sdim | Save_id NUMBER ID 365263508Sdim = { 366263508Sdim char buf[80]; 367263508Sdim 368263508Sdim (void) snprintf(buf, 80, "%s%d%s", $1, $2, $3); 369263508Sdim $$ = ns(buf); free($1); 370263508Sdim } 371263508Sdim | Save_id NUMBER ID NUMBER 372263508Sdim = { 373263508Sdim char buf[80]; 374263508Sdim 375263508Sdim (void) snprintf(buf, 80, "%s%d%s%d", $1, $2, $3, $4); 376263508Sdim $$ = ns(buf); free($1); 377263508Sdim } 378263508Sdim | Save_id NUMBER ID NUMBER ID 379263508Sdim = { 380263508Sdim char buf[80]; 381263508Sdim 382263508Sdim (void) snprintf(buf, 80, "%s%d%s%d%s", 383263508Sdim $1, $2, $3, $4, $5); 384263508Sdim $$ = ns(buf); free($1); 385263508Sdim } 386263508Sdim ; 387263508Sdim 388263508SdimOpt_list: 389263508Sdim Opt_list COMMA Option 390263508Sdim | 391263508Sdim Option 392263508Sdim ; 393263508Sdim 394263508SdimOption: 395263508Sdim Save_id 396263508Sdim = { 397263508Sdim struct opt *op = (struct opt *)malloc(sizeof (struct opt)); 398263508Sdim char *s; 399263508Sdim memset(op, 0, sizeof(*op)); 400263508Sdim op->op_name = ns($1); 401263508Sdim op->op_next = opt; 402263508Sdim op->op_value = 0; 403263508Sdim opt = op; 404263508Sdim if (s = strchr(op->op_name, '=')) { 405263508Sdim /* AARGH!!!! Old-style bogon */ 406263508Sdim *s = '\0'; 407263508Sdim op->op_value = ns(s + 1); 408263508Sdim } 409263508Sdim free(temp_id); 410263508Sdim } | 411263508Sdim Save_id EQUALS Opt_value 412263508Sdim = { 413263508Sdim struct opt *op = (struct opt *)malloc(sizeof (struct opt)); 414263508Sdim memset(op, 0, sizeof(*op)); 415263508Sdim op->op_name = ns($1); 416263508Sdim op->op_next = opt; 417263508Sdim op->op_value = ns($3); 418263508Sdim opt = op; 419263508Sdim free(temp_id); 420263508Sdim free(val_id); 421263508Sdim } ; 422263508Sdim 423263508SdimOpt_value: 424263508Sdim ID 425263508Sdim = { $$ = val_id = ns($1); } | 426263508Sdim NUMBER 427263508Sdim = { 428263508Sdim char nb[16]; 429263508Sdim (void) sprintf(nb, "%d", $1); 430263508Sdim $$ = val_id = ns(nb); 431263508Sdim } ; 432263508Sdim 433263508Sdim 434263508SdimSave_id: 435263508Sdim ID 436263508Sdim = { $$ = temp_id = ns($1); } 437263508Sdim ; 438263508Sdim 439263508SdimMkopt_list: 440263508Sdim Mkopt_list COMMA Mkoption 441263508Sdim | 442263508Sdim Mkoption 443263508Sdim ; 444263508Sdim 445263508SdimMkoption: 446263508Sdim Save_id EQUALS Opt_value 447263508Sdim = { 448263508Sdim struct opt *op = (struct opt *)malloc(sizeof (struct opt)); 449263508Sdim memset(op, 0, sizeof(*op)); 450263508Sdim op->op_name = ns($1); 451263508Sdim op->op_ownfile = 0; /* for now */ 452263508Sdim op->op_next = mkopt; 453263508Sdim op->op_value = ns($3); 454263508Sdim mkopt = op; 455263508Sdim free(temp_id); 456263508Sdim free(val_id); 457263508Sdim } ; 458263508Sdim 459263508SdimDev: 460263508Sdim ID 461263508Sdim = { $$ = ns($1); } 462263508Sdim ; 463263508Sdim 464263508SdimDevice_spec: 465263508Sdim DEVICE Dev_name Dev_info Int_spec 466263508Sdim = { cur.d_type = DEVICE; } | 467263508Sdim MASTER Dev_name Dev_info Int_spec 468263508Sdim = { cur.d_type = MASTER; } | 469263508Sdim DISK Dev_name Dev_info Int_spec 470263508Sdim = { cur.d_dk = 1; cur.d_type = DEVICE; } | 471263508Sdim CONTROLLER Dev_name Dev_info Int_spec 472263508Sdim = { cur.d_type = CONTROLLER; } | 473263508Sdim PSEUDO_DEVICE Init_dev Dev 474263508Sdim = { 475263508Sdim cur.d_name = $3; 476263508Sdim cur.d_type = PSEUDO_DEVICE; 477263508Sdim } | 478263508Sdim PSEUDO_DEVICE Init_dev Dev NUMBER 479263508Sdim = { 480263508Sdim cur.d_name = $3; 481263508Sdim cur.d_type = PSEUDO_DEVICE; 482263508Sdim cur.d_slave = $4; 483263508Sdim } | 484263508Sdim PSEUDO_DEVICE Dev_name Cdev_init Cdev_info 485263508Sdim = { 486263508Sdim if (!eq(cur.d_name, "cd")) 487263508Sdim yyerror("improper spec for pseudo-device"); 488263508Sdim seen_cd = 1; 489263508Sdim cur.d_type = DEVICE; 490263508Sdim verifycomp(*compp); 491263508Sdim }; 492263508Sdim 493263508SdimCdev_init: 494263508Sdim /* lambda */ 495263508Sdim = { mkcomp(&cur); }; 496263508Sdim 497263508SdimCdev_info: 498263508Sdim optional_on comp_device_list comp_option_list 499263508Sdim ; 500263508Sdim 501263508Sdimcomp_device_list: 502263508Sdim comp_device_list AND comp_device 503263508Sdim | comp_device 504263508Sdim ; 505263508Sdim 506263508Sdimcomp_device: 507263508Sdim comp_device_spec 508263508Sdim = { addcomp(*compp, $1); } 509263508Sdim ; 510263508Sdim 511263508Sdimcomp_device_spec: 512263508Sdim device_name 513263508Sdim = { 514263508Sdim struct file_list *fl = newflist(COMPSPEC); 515263508Sdim 516263508Sdim fl->f_compdev = nametodev($1, 0, COMPATIBILITY_SLICE, 517263508Sdim 'c'); 518263508Sdim fl->f_fn = devtoname(fl->f_compdev); 519263508Sdim $$ = fl; 520263508Sdim } 521251662Sdim | major_minor 522249259Sdim = { 523249259Sdim struct file_list *fl = newflist(COMPSPEC); 524263508Sdim 525263508Sdim fl->f_compdev = $1; 526263508Sdim fl->f_fn = devtoname($1); 527263508Sdim $$ = fl; 528263508Sdim } 529263508Sdim ; 530263508Sdim 531263508Sdimcomp_option_list: 532263508Sdim comp_option_list comp_option 533263508Sdim | 534263508Sdim /* lambda */ 535263508Sdim ; 536263508Sdim 537263508Sdimcomp_option: 538263508Sdim INTERLEAVE NUMBER 539263508Sdim = { cur.d_pri = $2; } | 540263508Sdim FLAGS NUMBER 541263508Sdim = { cur.d_flags = $2; }; 542263508Sdim 543263508SdimDev_name: 544263508Sdim Init_dev Dev NUMBER 545263508Sdim = { 546263508Sdim cur.d_name = $2; 547263508Sdim if (eq($2, "mba")) 548263508Sdim seen_mba = 1; 549263508Sdim else if (eq($2, "uba")) 550263508Sdim seen_uba = 1; 551263508Sdim else if (eq($2, "vba")) 552263508Sdim seen_vba = 1; 553263508Sdim else if (eq($2, "isa")) 554263508Sdim seen_isa = 1; 555263508Sdim else if (eq($2, "scbus")) 556263508Sdim seen_scbus = 1; 557263508Sdim cur.d_unit = $3; 558263508Sdim }; 559263508Sdim 560263508SdimInit_dev: 561263508Sdim /* lambda */ 562263508Sdim = { init_dev(&cur); }; 563263508Sdim 564263508SdimDev_info: 565263508Sdim Con_info Info_list 566263508Sdim | 567263508Sdim /* lambda */ 568263508Sdim ; 569263508Sdim 570263508SdimCon_info: 571263508Sdim AT Dev NUMBER 572263508Sdim = { 573263508Sdim if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { 574263508Sdim (void) sprintf(errbuf, 575263508Sdim "%s must be connected to a nexus", cur.d_name); 576263508Sdim yyerror(errbuf); 577263508Sdim } 578263508Sdim cur.d_conn = connect($2, $3); 579263508Sdim } | 580263508Sdim AT NEXUS NUMBER 581263508Sdim = { check_nexus(&cur, $3); cur.d_conn = TO_NEXUS; }; 582263508Sdim 583263508SdimInfo_list: 584263508Sdim Info_list Info 585263508Sdim | 586263508Sdim /* lambda */ 587263508Sdim ; 588263508Sdim 589263508SdimInfo: 590263508Sdim CSR NUMBER 591263508Sdim = { cur.d_addr = $2; } | 592263508Sdim BUS NUMBER 593263508Sdim = { 594263508Sdim if (cur.d_conn != 0 && cur.d_conn->d_type == CONTROLLER) 595263508Sdim cur.d_slave = $2; 596263508Sdim else 597263508Sdim yyerror("can't specify a bus to something " 598263508Sdim "other than a controller"); 599263508Sdim } | 600263508Sdim TARGET NUMBER 601263508Sdim = { cur.d_target = $2; } | 602263508Sdim UNIT NUMBER 603263508Sdim = { cur.d_lun = $2; } | 604263508Sdim DRIVE NUMBER 605263508Sdim = { cur.d_drive = $2; } | 606263508Sdim SLAVE NUMBER 607263508Sdim = { 608263508Sdim if (cur.d_conn != 0 && cur.d_conn != TO_NEXUS && 609263508Sdim cur.d_conn->d_type == MASTER) 610263508Sdim cur.d_slave = $2; 611263508Sdim else 612263508Sdim yyerror("can't specify slave--not to master"); 613263508Sdim } | 614263508Sdim IRQ NUMBER 615263508Sdim = { cur.d_irq = $2; } | 616263508Sdim DRQ NUMBER 617263508Sdim = { cur.d_drq = $2; } | 618263508Sdim IOMEM NUMBER 619263508Sdim = { cur.d_maddr = $2; } | 620263508Sdim IOSIZ NUMBER 621263508Sdim = { cur.d_msize = $2; } | 622263508Sdim PORT device_name 623263508Sdim = { cur.d_port = ns($2); } | 624263508Sdim PORT NUMBER 625263508Sdim = { cur.d_portn = $2; } | 626263508Sdim PORT AUTO 627263508Sdim = { cur.d_portn = -1; } | 628263508Sdim PORT NONE 629263508Sdim = { cur.d_portn = -2; } | 630263508Sdim TTY 631263508Sdim = { cur.d_mask = "tty"; } | 632263508Sdim BIO 633263508Sdim = { cur.d_mask = "bio"; } | 634263508Sdim NET 635263508Sdim = { cur.d_mask = "net"; } | 636263508Sdim FLAGS NUMBER 637263508Sdim = { cur.d_flags = $2; } | 638263508Sdim DISABLE 639263508Sdim = { cur.d_disabled = 1; } | 640263508Sdim CONFLICTS 641263508Sdim = { cur.d_conflicts = 1; }; 642263508Sdim 643263508SdimInt_spec: 644263508Sdim VECTOR Id_list 645263508Sdim = { cur.d_vec = $2; } | 646263508Sdim PRIORITY NUMBER 647263508Sdim = { cur.d_pri = $2; } | 648263508Sdim /* lambda */ 649263508Sdim ; 650263508Sdim 651263508SdimId_list: 652263508Sdim Save_id 653263508Sdim = { 654263508Sdim struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); 655263508Sdim memset(a, 0, sizeof(*a)); 656263508Sdim a->id = $1; a->id_next = 0; $$ = a; 657263508Sdim } | 658263508Sdim Save_id Id_list = 659263508Sdim { 660263508Sdim struct idlst *a = (struct idlst *)malloc(sizeof(struct idlst)); 661263508Sdim memset(a, 0, sizeof(*a)); 662263508Sdim a->id = $1; a->id_next = $2; $$ = a; 663263508Sdim }; 664263508Sdim 665263508Sdim%% 666263508Sdim 667263508Sdimyyerror(s) 668263508Sdim char *s; 669263508Sdim{ 670263508Sdim 671263508Sdim fprintf(stderr, "config: line %d: %s\n", yyline + 1, s); 672263508Sdim} 673263508Sdim 674263508Sdim/* 675263508Sdim * return the passed string in a new space 676263508Sdim */ 677263508Sdimchar * 678263508Sdimns(str) 679263508Sdim register char *str; 680263508Sdim{ 681263508Sdim register char *cp; 682263508Sdim 683263508Sdim cp = malloc((unsigned)(strlen(str)+1)); 684263508Sdim (void) strcpy(cp, str); 685263508Sdim return (cp); 686263508Sdim} 687263508Sdim 688263508Sdim/* 689263508Sdim * add a device to the list of devices 690263508Sdim */ 691263508Sdimnewdev(dp) 692263508Sdim register struct device *dp; 693263508Sdim{ 694263508Sdim register struct device *np; 695263508Sdim 696263508Sdim np = (struct device *) malloc(sizeof *np); 697263508Sdim memset(np, 0, sizeof(*np)); 698263508Sdim *np = *dp; 699263508Sdim np->d_next = 0; 700263508Sdim if (curp == 0) 701263508Sdim dtab = np; 702263508Sdim else 703263508Sdim curp->d_next = np; 704263508Sdim curp = np; 705263508Sdim} 706263508Sdim 707263508Sdim/* 708263508Sdim * note that a configuration should be made 709263508Sdim */ 710263508Sdimmkconf(sysname) 711263508Sdim char *sysname; 712263508Sdim{ 713263508Sdim register struct file_list *fl, **flp; 714263508Sdim 715263508Sdim fl = (struct file_list *) malloc(sizeof *fl); 716263508Sdim memset(fl, 0, sizeof(*fl)); 717263508Sdim fl->f_type = SYSTEMSPEC; 718263508Sdim fl->f_needs = sysname; 719263508Sdim fl->f_rootdev = NODEV; 720263508Sdim fl->f_dumpdev = NODEV; 721263508Sdim fl->f_fn = 0; 722263508Sdim fl->f_next = 0; 723263508Sdim for (flp = confp; *flp; flp = &(*flp)->f_next) 724263508Sdim ; 725263508Sdim *flp = fl; 726263508Sdim confp = flp; 727263508Sdim} 728263508Sdim 729263508Sdimstruct file_list * 730263508Sdimnewflist(ftype) 731263508Sdim u_char ftype; 732263508Sdim{ 733263508Sdim struct file_list *fl = (struct file_list *)malloc(sizeof (*fl)); 734263508Sdim memset(fl, 0, sizeof(*fl)); 735263508Sdim 736263508Sdim fl->f_type = ftype; 737263508Sdim fl->f_next = 0; 738263508Sdim fl->f_swapdev = NODEV; 739263508Sdim fl->f_swapsize = 0; 740263508Sdim fl->f_needs = 0; 741263508Sdim fl->f_fn = 0; 742263508Sdim return (fl); 743263508Sdim} 744263508Sdim 745263508Sdim/* 746263508Sdim * Add a swap device to the system's configuration 747263508Sdim */ 748263508Sdimmkswap(system, fl, size, flag) 749263508Sdim struct file_list *system, *fl; 750263508Sdim int size, flag; 751263508Sdim{ 752263508Sdim register struct file_list **flp; 753263508Sdim char name[80]; 754263508Sdim 755263508Sdim if (system == 0 || system->f_type != SYSTEMSPEC) { 756263508Sdim yyerror("\"swap\" spec precedes \"config\" specification"); 757263508Sdim return; 758263508Sdim } 759263508Sdim if (size < 0) { 760263508Sdim yyerror("illegal swap partition size"); 761263508Sdim return; 762263508Sdim } 763263508Sdim /* 764263508Sdim * Append swap description to the end of the list. 765263508Sdim */ 766263508Sdim flp = &system->f_next; 767263508Sdim for (; *flp && (*flp)->f_type == SWAPSPEC; flp = &(*flp)->f_next) 768263508Sdim ; 769263508Sdim fl->f_next = *flp; 770263508Sdim *flp = fl; 771263508Sdim fl->f_swapsize = size; 772263508Sdim fl->f_swapflag = flag; 773263508Sdim /* 774263508Sdim * If first swap device for this system, 775263508Sdim * set up f_fn field to insure swap 776263508Sdim * files are created with unique names. 777263508Sdim */ 778263508Sdim if (system->f_fn) 779263508Sdim return; 780263508Sdim if (eq(fl->f_fn, "generic")) 781263508Sdim system->f_fn = ns(fl->f_fn); 782263508Sdim else 783263508Sdim system->f_fn = ns(system->f_needs); 784263508Sdim} 785263508Sdim 786263508Sdimmkcomp(dp) 787263508Sdim register struct device *dp; 788263508Sdim{ 789263508Sdim register struct file_list *fl, **flp; 790263508Sdim char buf[80]; 791263508Sdim 792263508Sdim fl = (struct file_list *) malloc(sizeof *fl); 793263508Sdim memset(fl, 0, sizeof(*fl)); 794263508Sdim fl->f_type = COMPDEVICE; 795263508Sdim fl->f_compinfo = dp->d_unit; 796263508Sdim fl->f_fn = ns(dp->d_name); 797263508Sdim (void) sprintf(buf, "%s%d", dp->d_name, dp->d_unit); 798263508Sdim fl->f_needs = ns(buf); 799263508Sdim fl->f_next = 0; 800263508Sdim for (flp = compp; *flp; flp = &(*flp)->f_next) 801263508Sdim ; 802263508Sdim *flp = fl; 803263508Sdim compp = flp; 804263508Sdim} 805263508Sdim 806263508Sdimaddcomp(compdev, fl) 807263508Sdim struct file_list *compdev, *fl; 808263508Sdim{ 809263508Sdim register struct file_list **flp; 810263508Sdim char name[80]; 811263508Sdim 812263508Sdim if (compdev == 0 || compdev->f_type != COMPDEVICE) { 813263508Sdim yyerror("component spec precedes device specification"); 814263508Sdim return; 815263508Sdim } 816263508Sdim /* 817263508Sdim * Append description to the end of the list. 818263508Sdim */ 819263508Sdim flp = &compdev->f_next; 820263508Sdim for (; *flp && (*flp)->f_type == COMPSPEC; flp = &(*flp)->f_next) 821263508Sdim ; 822263508Sdim fl->f_next = *flp; 823263508Sdim *flp = fl; 824263508Sdim} 825263508Sdim 826263508Sdim/* 827263508Sdim * find the pointer to connect to the given device and number. 828263508Sdim * returns 0 if no such device and prints an error message 829263508Sdim */ 830263508Sdimstruct device * 831263508Sdimconnect(dev, num) 832263508Sdim register char *dev; 833263508Sdim register int num; 834263508Sdim{ 835263508Sdim register struct device *dp; 836263508Sdim struct device *huhcon(); 837263508Sdim 838263508Sdim if (num == QUES) 839263508Sdim return (huhcon(dev)); 840263508Sdim for (dp = dtab; dp != 0; dp = dp->d_next) { 841263508Sdim if ((num != dp->d_unit) || !eq(dev, dp->d_name)) 842263508Sdim continue; 843263508Sdim if (dp->d_type != CONTROLLER && dp->d_type != MASTER) { 844263508Sdim (void) sprintf(errbuf, 845263508Sdim "%s connected to non-controller", dev); 846263508Sdim yyerror(errbuf); 847263508Sdim return (0); 848263508Sdim } 849263508Sdim return (dp); 850263508Sdim } 851263508Sdim (void) sprintf(errbuf, "%s %d not defined", dev, num); 852263508Sdim yyerror(errbuf); 853263508Sdim return (0); 854263508Sdim} 855263508Sdim 856263508Sdim/* 857263508Sdim * connect to an unspecific thing 858263508Sdim */ 859263508Sdimstruct device * 860263508Sdimhuhcon(dev) 861263508Sdim register char *dev; 862263508Sdim{ 863263508Sdim register struct device *dp, *dcp; 864263508Sdim struct device rdev; 865263508Sdim int oldtype; 866263508Sdim 867263508Sdim /* 868263508Sdim * First make certain that there are some of these to wildcard on 869263508Sdim */ 870263508Sdim for (dp = dtab; dp != 0; dp = dp->d_next) 871263508Sdim if (eq(dp->d_name, dev)) 872263508Sdim break; 873263508Sdim if (dp == 0) { 874263508Sdim (void) sprintf(errbuf, "no %s's to wildcard", dev); 875263508Sdim yyerror(errbuf); 876263508Sdim return (0); 877263508Sdim } 878263508Sdim oldtype = dp->d_type; 879263508Sdim dcp = dp->d_conn; 880263508Sdim /* 881263508Sdim * Now see if there is already a wildcard entry for this device 882263508Sdim * (e.g. Search for a "uba ?") 883263508Sdim */ 884263508Sdim for (; dp != 0; dp = dp->d_next) 885263508Sdim if (eq(dev, dp->d_name) && dp->d_unit == -1) 886263508Sdim break; 887263508Sdim /* 888263508Sdim * If there isn't, make one because everything needs to be connected 889263508Sdim * to something. 890263508Sdim */ 891263508Sdim if (dp == 0) { 892263508Sdim dp = &rdev; 893263508Sdim init_dev(dp); 894263508Sdim dp->d_unit = QUES; 895263508Sdim dp->d_name = ns(dev); 896263508Sdim dp->d_type = oldtype; 897263508Sdim newdev(dp); 898263508Sdim dp = curp; 899263508Sdim /* 900263508Sdim * Connect it to the same thing that other similar things are 901263508Sdim * connected to, but make sure it is a wildcard unit 902263508Sdim * (e.g. up connected to sc ?, here we make connect sc? to a 903263508Sdim * uba?). If other things like this are on the NEXUS or 904263508Sdim * if they aren't connected to anything, then make the same 905263508Sdim * connection, else call ourself to connect to another 906263508Sdim * unspecific device. 907263508Sdim */ 908263508Sdim if (dcp == TO_NEXUS || dcp == 0) 909263508Sdim dp->d_conn = dcp; 910263508Sdim else 911263508Sdim dp->d_conn = connect(dcp->d_name, QUES); 912263508Sdim } 913263508Sdim return (dp); 914263508Sdim} 915263508Sdim 916263508Sdiminit_dev(dp) 917263508Sdim register struct device *dp; 918263508Sdim{ 919263508Sdim 920263508Sdim dp->d_name = "OHNO!!!"; 921263508Sdim dp->d_type = DEVICE; 922263508Sdim dp->d_conn = 0; 923263508Sdim dp->d_conflicts = 0; 924263508Sdim dp->d_disabled = 0; 925263508Sdim dp->d_vec = 0; 926263508Sdim dp->d_addr = dp->d_flags = dp->d_dk = 0; 927263508Sdim dp->d_pri = -1; 928263508Sdim dp->d_slave = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = UNKNOWN; 929263508Sdim dp->d_port = (char *)0; 930263508Sdim dp->d_portn = 0; 931263508Sdim dp->d_irq = -1; 932263508Sdim dp->d_drq = -1; 933263508Sdim dp->d_maddr = 0; 934263508Sdim dp->d_msize = 0; 935263508Sdim dp->d_mask = "null"; 936263508Sdim} 937263508Sdim 938263508Sdim/* 939263508Sdim * make certain that this is a reasonable type of thing to connect to a nexus 940263508Sdim */ 941263508Sdimcheck_nexus(dev, num) 942263508Sdim register struct device *dev; 943263508Sdim int num; 944263508Sdim{ 945263508Sdim 946263508Sdim switch (machine) { 947263508Sdim 948263508Sdim case MACHINE_VAX: 949263508Sdim if (!eq(dev->d_name, "uba") && !eq(dev->d_name, "mba") && 950263508Sdim !eq(dev->d_name, "bi")) 951263508Sdim yyerror("only uba's, mba's, and bi's should be connected to the nexus"); 952263508Sdim if (num != QUES) 953263508Sdim yyerror("can't give specific nexus numbers"); 954263508Sdim break; 955263508Sdim 956263508Sdim case MACHINE_TAHOE: 957263508Sdim if (!eq(dev->d_name, "vba")) 958263508Sdim yyerror("only vba's should be connected to the nexus"); 959263508Sdim break; 960263508Sdim 961263508Sdim case MACHINE_HP300: 962263508Sdim case MACHINE_LUNA68K: 963263508Sdim if (num != QUES) 964263508Sdim dev->d_addr = num; 965263508Sdim break; 966263508Sdim 967263508Sdim case MACHINE_I386: 968263508Sdim if (!eq(dev->d_name, "isa")) 969263508Sdim yyerror("only isa's should be connected to the nexus"); 970263508Sdim break; 971263508Sdim 972263508Sdim case MACHINE_NEWS3400: 973263508Sdim if (!eq(dev->d_name, "iop") && !eq(dev->d_name, "hb") && 974263508Sdim !eq(dev->d_name, "vme")) 975263508Sdim yyerror("only iop's, hb's and vme's should be connected to the nexus"); 976263508Sdim break; 977263508Sdim } 978263508Sdim} 979263508Sdim 980263508Sdim/* 981263508Sdim * Check system specification and apply defaulting 982263508Sdim * rules on root, argument, dump, and swap devices. 983263508Sdim */ 984263508Sdimchecksystemspec(fl) 985263508Sdim register struct file_list *fl; 986263508Sdim{ 987263508Sdim char buf[BUFSIZ]; 988263508Sdim register struct file_list *swap; 989263508Sdim int generic; 990263508Sdim 991263508Sdim if (fl == 0 || fl->f_type != SYSTEMSPEC) { 992263508Sdim yyerror("internal error, bad system specification"); 993263508Sdim exit(1); 994263508Sdim } 995263508Sdim swap = fl->f_next; 996263508Sdim generic = swap && swap->f_type == SWAPSPEC && eq(swap->f_fn, "generic"); 997263508Sdim if (fl->f_rootdev == NODEV && !generic) { 998263508Sdim yyerror("no root device specified"); 999263508Sdim exit(1); 1000263508Sdim } 1001263508Sdim /* 1002263508Sdim * Default swap area to be in 'b' partition of root's 1003263508Sdim * device. If root specified to be other than on 'a' 1004263508Sdim * partition, give warning, something probably amiss. 1005263508Sdim */ 1006263508Sdim if (swap == 0 || swap->f_type != SWAPSPEC) { 1007263508Sdim dev_t dev; 1008263508Sdim 1009263508Sdim swap = newflist(SWAPSPEC); 1010263508Sdim dev = fl->f_rootdev; 1011263508Sdim if (dkpart(dev) != 0) { 1012263508Sdim (void) sprintf(buf, 1013263508Sdim"Warning, swap defaulted to 'b' partition with root on '%c' partition", 1014263508Sdim dkpart(dev) + 'a'); 1015263508Sdim yyerror(buf); 1016263508Sdim } 1017263508Sdim swap->f_swapdev = dkmodpart(dev, SWAP_PART); 1018263508Sdim swap->f_fn = devtoname(swap->f_swapdev); 1019263508Sdim mkswap(fl, swap, 0); 1020263508Sdim } 1021263508Sdim /* 1022263508Sdim * Make sure a generic swap isn't specified, along with 1023263508Sdim * other stuff (user must really be confused). 1024263508Sdim */ 1025263508Sdim if (generic) { 1026263508Sdim if (fl->f_rootdev != NODEV) 1027263508Sdim yyerror("root device specified with generic swap"); 1028263508Sdim if (fl->f_dumpdev != NODEV) 1029263508Sdim yyerror("dump device specified with generic swap"); 1030263508Sdim return; 1031263508Sdim } 1032263508Sdim /* 1033263508Sdim * Warn if dump device is not a swap area. 1034263508Sdim */ 1035263508Sdim if (fl->f_dumpdev != NODEV && fl->f_dumpdev != swap->f_swapdev) { 1036263508Sdim struct file_list *p = swap->f_next; 1037263508Sdim 1038263508Sdim for (; p && p->f_type == SWAPSPEC; p = p->f_next) 1039263508Sdim if (fl->f_dumpdev == p->f_swapdev) 1040263508Sdim return; 1041263508Sdim (void) sprintf(buf, 1042263508Sdim "Warning: dump device is not a swap partition"); 1043263508Sdim yyerror(buf); 1044263508Sdim } 1045263508Sdim} 1046263508Sdim 1047263508Sdim/* 1048263508Sdim * Verify all devices specified in the system specification 1049263508Sdim * are present in the device specifications. 1050263508Sdim */ 1051263508Sdimverifysystemspecs() 1052263508Sdim{ 1053263508Sdim register struct file_list *fl; 1054263508Sdim dev_t checked[50], *verifyswap(); 1055263508Sdim register dev_t *pchecked = checked; 1056263508Sdim 1057263508Sdim for (fl = conf_list; fl; fl = fl->f_next) { 1058263508Sdim if (fl->f_type != SYSTEMSPEC) 1059263508Sdim continue; 1060263508Sdim if (!finddev(fl->f_rootdev)) 1061263508Sdim deverror(fl->f_needs, "root"); 1062263508Sdim *pchecked++ = fl->f_rootdev; 1063263508Sdim pchecked = verifyswap(fl->f_next, checked, pchecked); 1064263508Sdim if (!alreadychecked(fl->f_dumpdev, checked, pchecked)) { 1065263508Sdim if (!finddev(fl->f_dumpdev)) 1066263508Sdim deverror(fl->f_needs, "dump"); 1067263508Sdim *pchecked++ = fl->f_dumpdev; 1068263508Sdim } 1069263508Sdim } 1070263508Sdim} 1071263508Sdim 1072263508Sdim/* 1073263508Sdim * Do as above, but for swap devices. 1074263508Sdim */ 1075263508Sdimdev_t * 1076263508Sdimverifyswap(fl, checked, pchecked) 1077263508Sdim register struct file_list *fl; 1078263508Sdim dev_t checked[]; 1079263508Sdim register dev_t *pchecked; 1080263508Sdim{ 1081263508Sdim 1082263508Sdim for (;fl && fl->f_type == SWAPSPEC; fl = fl->f_next) { 1083263508Sdim if (eq(fl->f_fn, "generic")) 1084263508Sdim continue; 1085263508Sdim if (alreadychecked(fl->f_swapdev, checked, pchecked)) 1086263508Sdim continue; 1087263508Sdim if (!finddev(fl->f_swapdev)) 1088263508Sdim fprintf(stderr, 1089263508Sdim "config: swap device %s not configured", fl->f_fn); 1090263508Sdim *pchecked++ = fl->f_swapdev; 1091263508Sdim } 1092263508Sdim return (pchecked); 1093263508Sdim} 1094263508Sdim 1095263508Sdim/* 1096263508Sdim * Verify that components of a compound device have themselves been config'ed 1097263508Sdim */ 1098263508Sdimverifycomp(fl) 1099263508Sdim register struct file_list *fl; 1100263508Sdim{ 1101263508Sdim char *dname = fl->f_needs; 1102263508Sdim 1103263508Sdim for (fl = fl->f_next; fl; fl = fl->f_next) { 1104263508Sdim if (fl->f_type != COMPSPEC || finddev(fl->f_compdev)) 1105263508Sdim continue; 1106263508Sdim fprintf(stderr, 1107263508Sdim "config: %s: component device %s not configured\n", 1108263508Sdim dname, fl->f_needs); 1109263508Sdim } 1110263508Sdim} 1111263508Sdim 1112263508Sdim/* 1113263508Sdim * Has a device already been checked 1114263508Sdim * for its existence in the configuration? 1115263508Sdim */ 1116263508Sdimalreadychecked(dev, list, last) 1117263508Sdim dev_t dev, list[]; 1118263508Sdim register dev_t *last; 1119263508Sdim{ 1120263508Sdim register dev_t *p; 1121263508Sdim 1122263508Sdim for (p = list; p < last; p++) 1123263508Sdim if (dkmodpart(*p, 0) != dkmodpart(dev, 0)) 1124263508Sdim return (1); 1125263508Sdim return (0); 1126263508Sdim} 1127263508Sdim 1128263508Sdimdeverror(systemname, devtype) 1129263508Sdim char *systemname, *devtype; 1130263508Sdim{ 1131263508Sdim 1132263508Sdim fprintf(stderr, "config: %s: %s device not configured\n", 1133263508Sdim systemname, devtype); 1134263508Sdim} 1135263508Sdim 1136263508Sdim/* 1137263508Sdim * Look for the device in the list of 1138263508Sdim * configured hardware devices. Must 1139263508Sdim * take into account stuff wildcarded. 1140263508Sdim */ 1141263508Sdim/*ARGSUSED*/ 1142263508Sdimfinddev(dev) 1143263508Sdim dev_t dev; 1144263508Sdim{ 1145263508Sdim 1146263508Sdim /* punt on this right now */ 1147263508Sdim return (1); 1148263508Sdim} 1149263508Sdim