9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Ronald G Minnich <rminnich@lanl.gov>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: [9fans] impressive
Date: Mon, 24 Apr 2006 14:37:21 -0600	[thread overview]
Message-ID: <444D3701.50303@lanl.gov> (raw)

This program:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <unistd.h>
#include <stdio.h>

main (int argc, char *argv[])
{
     unsigned char buf[8], *p;
     int fd_msr, i;
     unsigned long addr = 0;

     if (argc < 3) {
         printf("usage:wrmsr reg value\n");
         exit(1);
     }
     addr = strtoul(argv[1], NULL, 0);
     p = argv[2];

     printf("MSR register 0x%lx => ", addr);
     for (i = 7; i > 0; i--) {
         buf[i] = strtol(p, &p, 16);
         p++;
         printf("%2.2x:", buf[i]);
     }
     buf[i] = strtol(p, &p, 16);
     printf("%2.2x\n", buf[i]);

     fd_msr = open("/dev/cpu/0/msr", O_WRONLY);
     lseek(fd_msr, addr, SEEK_SET);
     if (write(fd_msr, buf, 8) < 0)
         perror("");
}

compiles to a 512KB binary on linux with -static

Well, *I'm* impressed anyway.

[[ standard old guy story about "my first Unix box" and "nobody knows
the value of 2 bits anymore" and "what's with these GNU kids today"
deleted -- ed.]]

yy* symbols are in there btw. And, don't worry, some pthreads symbols
made it in as well. Don't want main() to be too lonely!

ron


             reply	other threads:[~2006-04-24 20:37 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-24 20:37 Ronald G Minnich [this message]
2006-04-24 20:51 ` Charles Forsyth
2006-04-24 21:32 ` Brantley Coile
2006-04-25 11:06   ` Anthony Sorace
2006-04-25 11:08     ` Anthony Sorace
2006-04-25  2:15 ` Derek Fawcus
2006-04-25  2:23   ` Roman Shaposhnick
2006-04-25  2:37     ` Derek Fawcus
2006-04-25  3:51       ` Roman Shaposhnick
2006-04-25  8:17         ` Derek Fawcus
2006-04-25 17:53           ` Roman Shaposhnick
2006-04-26  1:11             ` Derek Fawcus
2006-04-26  1:19               ` Roman Shaposhnick
2006-04-26  2:12                 ` Derek Fawcus
2006-04-25  3:02   ` Andy Newman
2006-04-25  3:13     ` Ronald G Minnich
2006-04-25 19:57     ` Dan Cross
2006-04-25  2:30 erik quanstrom
2006-04-25  2:48 ` Derek Fawcus
2006-04-25 10:20 erik quanstrom
2006-04-26  0:26 erik quanstrom
2006-04-26  0:48 ` geoff
2006-04-26  0:54   ` Roman Shaposhnick
2006-04-26  0:53 ` Roman Shaposhnick
2006-04-26  2:15   ` Taj Khattra
2006-04-26  4:59     ` David Leimbach
2006-04-26 12:37       ` Anthony Sorace
2006-04-26 15:28     ` Rian Hunter
2006-04-26 16:39     ` Micah Stetson
2006-04-26 18:02       ` Bruce Ellis
2006-04-26 20:14         ` Micah Stetson
2006-05-08 14:50       ` Harri Haataja
2006-05-08 15:04         ` LiteStar numnums
2006-05-08 15:12           ` Charles Forsyth
2006-05-08 20:08             ` Micah Stetson
2006-05-08 20:52             ` LiteStar numnums
2006-05-08 21:10               ` Jack Johnson
2006-05-08 21:17                 ` andrey mirtchovski
2006-05-08 21:18                 ` Paul Lalonde
2006-05-08 22:25                 ` Francisco J Ballesteros
2006-05-09 21:56                   ` Dave Eckhardt
2006-05-10  0:13                     ` geoff
2006-05-10  8:39                       ` Lluís Batlle
2006-05-08 23:31                 ` geoff
2006-05-09  1:18                   ` Paul Lalonde
2006-05-09  1:39                     ` quanstro
2006-05-09  2:12                       ` Paul Lalonde
2006-05-09  2:20                         ` quanstro
2006-05-09  3:00                           ` Paul Lalonde
2006-05-09  9:32                             ` Bruce Ellis
2006-04-26 22:57     ` Roman Shaposhnick
2006-04-26  4:57 ` David Leimbach
2006-04-26  4:53   ` Ronald G Minnich
2006-04-26  5:11     ` Roman Shaposhnick
2006-04-26  0:55 erik quanstrom
2006-04-26  1:07 ` Roman Shaposhnick
2006-04-26  2:38 erik quanstrom
2006-04-26  3:24 jmk
2006-04-27  1:10 erik quanstrom
2006-04-27  2:06 ` Jack Johnson
2006-04-27  1:23 erik quanstrom
2006-04-27  5:08 ` Micah Stetson
2006-04-27  1:35 erik quanstrom
2006-04-27  2:13 erik quanstrom
2006-05-08 22:02 erik quanstrom
2006-05-10  0:45 erik quanstrom
2006-05-10  2:09 ` Lyndon Nerenberg
2006-05-10  3:35   ` David Arnold
2006-05-10  4:03     ` Lyndon Nerenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=444D3701.50303@lanl.gov \
    --to=rminnich@lanl.gov \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).