Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 19953)
+++ wp-includes/functions.php	(working copy)
@@ -1775,7 +1775,7 @@
 		'png' => 'image/png',
 		'bmp' => 'image/bmp',
 		'tif|tiff' => 'image/tiff',
-		'ico' => 'image/x-icon',
+		'ico' => 'image/vnd.microsoft.icon',
 		'asf|asx|wax|wmv|wmx' => 'video/asf',
 		'avi' => 'video/avi',
 		'divx' => 'video/divx',
Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 19953)
+++ wp-includes/general-template.php	(working copy)
@@ -1587,6 +1587,76 @@
 }
 
 /**
+ * Convenience function that echoes the HTML for the site's favicon icon.
+ * By default, automatically included in the header via the 'wp_head' action, which can be removed by themes if a custom favicon is desired.
+ * 
+ * @uses generate_site_favicon_html() to do the actual heavy lifting
+ */
+function site_favicon(){
+	echo generate_site_favicon_html();
+}
+add_action( 'wp_head', 'site_favicon' );
+add_action( 'admin_head', 'site_favicon' );
+
+/**
+ * Return the HTML for the site's favicon icon, if such has been defined.
+ * 
+ * @uses get_site_favicon_uri();
+ * 
+ * Includes the conditional tag wrapper for an IE (.ico) version. 
+ */
+function generate_site_favicon_html() {
+	$ie_favicon_uri = get_site_favicon_uri( 'ico' );
+	$favicon_uri = get_site_favicon_uri();
+
+	$content = "";
+	if (! is_wp_error( $ie_favicon_uri ) && ! is_wp_error( $favicon_uri ) ){
+
+		$content .= <<<FAVICON_HTML
+<!--Favicon (via 'wp_head' action) -->
+<!--[if IE]>
+<link rel="shortcut icon" href="{$ie_favicon_uri}" />
+<![endif]-->
+<!--[if !IE]>-->
+<link href="{$favicon_uri}" rel="icon" type="image/png" />
+<!--<![endif]-->
+FAVICON_HTML;
+    }
+	return $content;
+}
+
+/**
+ * Returns the URI for the site's favicon based on the option set in  Admin > Settings > General.
+ * 
+ * @param string $format png|ico default 'png'. Use 'ico' for serving up an IE-compatible ICO file
+ * @return mixed WP_Error | fully qualified URI 
+ */
+function get_site_favicon_uri( $format = 'png' ){
+	/** @TODO provide error checking for validity of $format and $size */
+	//return site_url( '/wp-content/uploads/2012/02/wp-favicon_' . $size . 'x' . $size . '.' . $format );
+	$error = null;
+
+	$favicon_basename = get_option ( 'sitefavicon' ); 
+	if ( ! empty( $favicon_basename ) ) {
+		$favicon_fullname = $favicon_basename . '-' . $format;
+		
+		$posts = get_posts( array( 'name' => $favicon_fullname, 'post_type' => 'attachment' ) );
+		if ( $posts[0] ){
+			$favicon_file = wp_get_attachment_url( $posts[0]->ID );
+				return $favicon_file ;
+		} else {
+			$error = new WP_Error( 'attachment_missing', __( "Favicon file '$favicon_fullname' not found." ) );
+		}
+	} else {
+		$error = new WP_Error( 'no_icon', __( "No favicon file provided." ) );
+	}
+
+	// We get here because of an error condition
+	/** @TODO default to the theme's favicon **/
+	return $error;
+}
+
+/**
  * Display the links to the general feeds.
  *
  * @since 2.8.0
Index: wp-includes/script-loader.php
===================================================================
--- wp-includes/script-loader.php	(revision 19953)
+++ wp-includes/script-loader.php	(working copy)
@@ -88,6 +88,8 @@
 
 	$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), false, 1 );
 
+	$scripts->add( 'wp-favicon', "/wp-admin/js/wp-favicon$suffix.js", array('jquery'), false, 1 );
+
 	$scripts->add( 'prototype', '/wp-includes/js/prototype.js', array(), '1.6.1');
 
 	$scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), false, 1 );
Index: wp-admin/js/wp-favicon.dev.js
===================================================================
--- wp-admin/js/wp-favicon.dev.js	(revision 0)
+++ wp-admin/js/wp-favicon.dev.js	(revision 0)
@@ -0,0 +1,12 @@
+(function($){
+    $('#faviconfile').change(function(){
+        // check the file extention
+        if (! $.inArray( $(this).val().split('.').pop().toLowerCase() , /* valid file extentions */ ['gif','png','jpg','jpeg'] ) ) 
+            $('#favicon-invalid-filetype').show();
+        else
+        {
+            $('#faviconupload').submit();
+        }
+    });
+
+})(jQuery);
Index: wp-admin/js/wp-favicon.js
===================================================================
--- wp-admin/js/wp-favicon.js	(revision 0)
+++ wp-admin/js/wp-favicon.js	(revision 0)
@@ -0,0 +1,12 @@
+(function($){
+    $('#faviconfile').change(function(){
+        // check the file extention
+        if (! $.inArray( $(this).val().split('.').pop().toLowerCase() , /* valid file extentions */ ['gif','png','jpg','jpeg'] ) ) 
+            $('#favicon-invalid-filetype').show();
+        else
+        {
+            $('#faviconupload').submit();
+        }
+    });
+
+})(jQuery);
Index: wp-admin/options-general.php
===================================================================
--- wp-admin/options-general.php	(revision 19953)
+++ wp-admin/options-general.php	(working copy)
@@ -81,6 +81,8 @@
 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
 );
 
+wp_enqueue_script('wp-favicon');
+
 include('./admin-header.php');
 ?>
 
@@ -88,6 +90,23 @@
 <?php screen_icon(); ?>
 <h2><?php echo esc_html( $title ); ?></h2>
 
+<form action="<?php echo admin_url('favicon-upload.php')?>" method="post" enctype="multipart/form-data" id="faviconupload">
+	<input type="hidden" name="action" value="wp_upload_favicon" />
+
+	<table class="form-table">
+		<tr valign="top">
+			<th scope="row"><label for="sitefavicon"><?php _e('Favicon') ?></label></th>
+			<td>
+				<?php //echo generate_media_thumbnail_link( 'options-general-favicon', 0,  __( 'Upload favicon image' ) ); ?>
+				<input class="button" name="avatarfile" type="file" id="faviconfile" size="20" />
+				<p class="submit no-js hide-if-js"><input type="submit" name="Submit" value="Upload Image &raquo;" id="faviconsubmit" /></p>
+				<span class="description no-js"><?php _e('Click to upload your own custom icon ("favicon") for your blog. You\'ll be able to crop and scale it once it\'s uploaded.') ?></span>
+			</td>
+		</tr>
+	</table>
+</form>
+
+
 <form method="post" action="options.php">
 <?php settings_fields('general'); ?>
 
